diff options
author | corvid <corvid@lavabit.com> | 2010-03-10 03:04:45 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2010-03-10 03:04:45 +0000 |
commit | f38796651aba1b54d4173f969cfafe0ae24b2cbc (patch) | |
tree | f0e0b994f2e35df91ef9ffd6c279688f3f2e1df2 /dpi/cookies.c | |
parent | b587c136dd179eed9d5acd1ec22248f42ef89d30 (diff) |
use tm for max-age
Diffstat (limited to 'dpi/cookies.c')
-rw-r--r-- | dpi/cookies.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/dpi/cookies.c b/dpi/cookies.c index 53015de5..d631f3bc 100644 --- a/dpi/cookies.c +++ b/dpi/cookies.c @@ -62,8 +62,6 @@ int main(void) #define _MSG(...) #define MSG(...) printf("[cookies dpi]: " __VA_ARGS__) -#define DILLO_TIME_MAX ((time_t) ((1UL << (sizeof(time_t) * 8 - 1)) - 1)) - /* * a_List_add() * @@ -739,13 +737,14 @@ static CookieData_t *Cookies_parse(char *cookie_str, const char *server_date) if (isdigit(*value) || *value == '-') { time_t now = time(NULL); long age = strtol(value, NULL, 10); + struct tm *tm = gmtime(&now); - cookie->expires_at = now + age; - if (age > 0 && - difftime(cookie->expires_at, cookies_epoch_time) < 0) { - /* handle overflow */ - cookie->expires_at = DILLO_TIME_MAX; + tm->tm_sec += age; + cookie->expires_at = mktime(tm); + if (age > 0 && cookie->expires_at == (time_t) -1) { + cookie->expires_at = cookies_future_time; } + MSG("Cookie to expire at %s", ctime(&cookie->expires_at)); expires = max_age = TRUE; } dFree(value); |