changeset 1614:d6624cbf9beb

make a point of using -1 for invalid time_t
author corvid <corvid@lavabit.com>
date Wed, 10 Mar 2010 03:20:12 +0000
parents 0f26b1d4ac2e
children 6f4cc0aa0d9b
files dpi/cookies.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/dpi/cookies.c	Wed Mar 10 03:07:08 2010 +0000
+++ b/dpi/cookies.c	Wed Mar 10 03:20:12 2010 +0000
@@ -329,6 +329,8 @@
             Cookies_tm_init(&tm);
             tm.tm_sec += strtol(piece, NULL, 10);
             cookie->expires_at = mktime(&tm);
+         } else {
+            cookie->expires_at = (time_t) -1;
          }
          cookie->name = dStrdup(dStrsep(&line_marker, "\t"));
          cookie->value = dStrdup(line_marker ? line_marker : "");
@@ -559,8 +561,9 @@
    /* Don't add an expired cookie. Whether expiring now == expired, exactly,
     * is arguable, but we definitely do not want to add a Max-Age=0 cookie.
     */
-   if (difftime(cookie->expires_at, time(NULL)) <= 0) {
-      _MSG("Goodbye, expired cookie %s=%s d:%s p:%s\n", cookie->name,
+   if ((cookie->expires_at == (time_t) -1) ||
+       (difftime(cookie->expires_at, time(NULL)) <= 0)) {
+      _MSG("Goodbye, cookie %s=%s d:%s p:%s\n", cookie->name,
            cookie->value, cookie->domain, cookie->path);
       Cookies_free_cookie(cookie);
    } else {