summaryrefslogtreecommitdiff
path: root/dpi
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2012-10-29 17:48:03 +0000
committercorvid <corvid@lavabit.com>2012-10-29 17:48:03 +0000
commit28a186ec337eee442d7ccc6af0335ee7c1813ad1 (patch)
tree41288c2e2fcb094cc21236865c4a2292085ce292 /dpi
parent6f88372a57ee0f1d22df745fe52f93326c5a0f4b (diff)
declarations at start of block
Diffstat (limited to 'dpi')
-rw-r--r--dpi/cookies.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/dpi/cookies.c b/dpi/cookies.c
index 10803211..95b2a9a3 100644
--- a/dpi/cookies.c
+++ b/dpi/cookies.c
@@ -805,6 +805,9 @@ static CookieData_t *Cookies_parse(char *cookie_str, const char *server_date)
/* Get the value for the attribute and store it */
if (first_attr) {
+ time_t now;
+ struct tm *tm;
+
if (*str != '=' || *attr == '\0') {
/* disregard nameless cookie */
dFree(attr);
@@ -815,8 +818,8 @@ static CookieData_t *Cookies_parse(char *cookie_str, const char *server_date)
cookie->value = Cookies_parse_value(&str);
/* let's arbitrarily initialise with a year for now */
- time_t now = time(NULL);
- struct tm *tm = gmtime(&now);
+ now = time(NULL);
+ tm = gmtime(&now);
++tm->tm_year;
cookie->expires_at = mktime(tm);
if (cookie->expires_at == (time_t) -1)
@@ -847,10 +850,12 @@ static CookieData_t *Cookies_parse(char *cookie_str, const char *server_date)
dFree(value);
} else if (dStrAsciiCasecmp(attr, "Expires") == 0) {
if (!max_age) {
+ struct tm *tm;
+
value = Cookies_parse_value(&str);
Cookies_unquote_string(value);
_MSG("Expires attribute gives %s\n", value);
- struct tm *tm = Cookies_parse_date(value);
+ tm = Cookies_parse_date(value);
if (tm) {
tm->tm_sec += Cookies_server_timediff(server_date);
cookie->expires_at = mktime(tm);