From: Fabian Keil <fk@fabiankeil.de>
Date: Tue, 16 Jun 2009 15:42:28 +0000 (+0000)
Subject: In case of strftime() failures in client_if_modified_since(), keep the original heade... 
X-Git-Tag: v_3_0_14~94
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/developer-manual/faq/@default-cgi@/static/gitweb.js?a=commitdiff_plain;h=4741aaab8093cb425b21dcd3fa693f2e9db8234b;p=privoxy.git

In case of strftime() failures in client_if_modified_since(), keep the original header around.

Lee's Privoxy-Regression-Test result seems to indicate that it may
fail on Windows if the generated date predates the Unix epoch.
---

diff --git a/parsers.c b/parsers.c
index 6768d3c8..6f19139c 100644
--- a/parsers.c
+++ b/parsers.c
@@ -1,4 +1,4 @@
-const char parsers_rcs[] = "$Id: parsers.c,v 1.177 2009/06/10 12:50:15 fabiankeil Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.178 2009/06/11 14:13:19 david__schmidt Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
@@ -3053,7 +3053,13 @@ static jb_err client_if_modified_since(struct client_state *csp, char **header)
 #else
             timeptr = gmtime(&tm);
 #endif
-            strftime(newheader, sizeof(newheader), "%a, %d %b %Y %H:%M:%S GMT", timeptr);
+            if (!strftime(newheader, sizeof(newheader),
+                    "%a, %d %b %Y %H:%M:%S GMT", timeptr))
+            {
+               log_error(LOG_LEVEL_ERROR,
+                  "Randomizing %s failed. Keeping the header unmodified.");
+               return JB_ERR_OK;
+            }
 
             freez(*header);
             *header = strdup("If-Modified-Since: ");