# HG changeset patch # User corvid # Date 1268190285 0 # Node ID 3eb2cd09244d91741aa27df449377c887342fe76 # Parent 0c8aeadcead3fb1732b00a7e3e9a37a4ca516669 use tm for max-age diff -r 0c8aeadcead3 -r 3eb2cd09244d dpi/cookies.c --- a/dpi/cookies.c Wed Mar 10 02:47:51 2010 +0000 +++ b/dpi/cookies.c Wed Mar 10 03:04:45 2010 +0000 @@ -62,8 +62,6 @@ #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 @@ 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);