Differences From:
File src/cgi.c part of check-in [aeeba751c4] - Fix a memory double-free'd problem.In function cgi_set_cookie the zDate was allocated via usage of cgi_rfc822_datestamp. But as it was appended to the blob extraHeader via the format specifier %z the memory was free'd by blob_appendf. As cgi_rfc822_datestamp might return both a dynamic allocated empty string as well as a dynamic allocated string containing the time stamp, blob_appendf should not try to free the zDate. So now the format specifier is changed to %s to let us decide, if we want to free the memory or not.
by cle on 2008-09-11 17:12:11. [view]
To:
File src/cgi.c part of check-in [3d62a9fb39] - Fix a few C99-isms in the code so that the code will build on older C compilers. by drh on 2008-10-06 11:33:23. [view]
@@ -200,10 +200,11 @@ int lifetime /* Expiration of the cookie in seconds from now */ ){ if( zPath==0 ) zPath = g.zTop; if( lifetime>0 ){ + char *zDate; lifetime += (int)time(0); - char * zDate = cgi_rfc822_datestamp(lifetime); + zDate = cgi_rfc822_datestamp(lifetime); blob_appendf(&extraHeader, "Set-Cookie: %s=%t; Path=%s; expires=%s; Version=1\r\n", zName, zValue, zPath, zDate); if( zDate[0] ) free( zDate ); @@ -288,10 +289,10 @@ } #endif if( g.fullHttpReply ){ - fprintf(g.httpOut, "HTTP/1.0 %d %s\r\n", iReplyStatus, zReplyStatus); - char * zDate = cgi_rfc822_datestamp(time(0)); + char *zDate = cgi_rfc822_datestamp(time(0)); + fprintf(g.httpOut, "HTTP/1.0 %d %s\r\n", iReplyStatus, zReplyStatus); fprintf(g.httpOut, "Date: %s\r\n", zDate ); if( zDate[0] ) free( zDate ); fprintf(g.httpOut, "Connection: close\r\n"); }else{