diff options
author | corvid <corvid@lavabit.com> | 2010-03-10 03:20:12 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2010-03-10 03:20:12 +0000 |
commit | 28879e9a8b620b5c8909f61e979a32e601f3bc2a (patch) | |
tree | beb59b62a134078c05d4677ec0f6f9a24a99bbfc | |
parent | 120b63fd295ff3cb49076a5acd8edb51c716377a (diff) |
make a point of using -1 for invalid time_t
-rw-r--r-- | dpi/cookies.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/dpi/cookies.c b/dpi/cookies.c index 0e100a8d..05846d5f 100644 --- a/dpi/cookies.c +++ b/dpi/cookies.c @@ -329,6 +329,8 @@ static void Cookies_init() 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 @@ static void Cookies_add_cookie(CookieData_t *cookie) /* 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 { |