From: Fabian Keil <fk@fabiankeil.de>
Date: Sat, 1 Dec 2007 13:04:22 +0000 (+0000)
Subject: Fix a crash on mingw32 with some Last Modified times in the future.
X-Git-Tag: v_3_0_7~24
X-Git-Url: http://www.privoxy.org/gitweb/@default-cgi@/faq/%22https:/developer-manual/static/@default-cgi@edit-actions-remove-url?a=commitdiff_plain;h=2075b53ccdc82ce7aee12cd1edc83c1872955e69;p=privoxy.git

Fix a crash on mingw32 with some Last Modified times in the future.
---

diff --git a/parsers.c b/parsers.c
index e89a6434..cb52fb6a 100644
--- a/parsers.c
+++ b/parsers.c
@@ -1,4 +1,4 @@
-const char parsers_rcs[] = "$Id: parsers.c,v 1.114 2007/10/19 16:56:26 fabiankeil Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.115 2007/11/02 16:52:50 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
@@ -44,6 +44,10 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.114 2007/10/19 16:56:26 fabiankei
  *
  * Revisions   :
  *    $Log: parsers.c,v $
+ *    Revision 1.115  2007/11/02 16:52:50  fabiankeil
+ *    Remove a "can't happen" error block which, over
+ *    time, mutated into a "guaranteed to happen" block.
+ *
  *    Revision 1.114  2007/10/19 16:56:26  fabiankeil
  *    - Downgrade "Buffer limit reached" message to LOG_LEVEL_INFO.
  *    - Use shiny new content_filters_enabled() in client_range().
@@ -2595,7 +2599,16 @@ static jb_err server_last_modified(struct client_state *csp, char **header)
          rtime = (long int)difftime(now, last_modified);
          if (rtime)
          {
+            int negative = 0;
+
+            if (rtime < 0)
+            {
+               rtime *= -1; 
+               negative = 1;
+               log_error(LOG_LEVEL_HEADER, "Server time in the future.");
+            }
             rtime = pick_from_range(rtime);
+            if (negative) rtime *= -1;
             last_modified += rtime;
 #ifdef HAVE_GMTIME_R
             timeptr = gmtime_r(&last_modified, &gmt);