From 4741aaab8093cb425b21dcd3fa693f2e9db8234b Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Tue, 16 Jun 2009 15:42:28 +0000 Subject: [PATCH] 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. --- parsers.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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: "); -- 2.39.2