summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2010-01-12 00:27:14 +0000
committercorvid <corvid@lavabit.com>2010-01-12 00:27:14 +0000
commit388754c08adb5da535d94690ae327d0e2493e89c (patch)
tree5f3588b441d349605a3cf70b9e562d46688d0b35
parent61f64402d7f4efbff0e2c8e1d0f38787365b7138 (diff)
don't bother to save expired cookies
-rw-r--r--dpi/cookies.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/dpi/cookies.c b/dpi/cookies.c
index dc355f04..7bef14ff 100644
--- a/dpi/cookies.c
+++ b/dpi/cookies.c
@@ -343,6 +343,7 @@ static void Cookies_save_and_free()
int i, fd;
CookieNode *node;
CookieData_t *cookie;
+ time_t now;
#ifndef HAVE_LOCKF
struct flock lck;
@@ -351,6 +352,8 @@ static void Cookies_save_and_free()
if (disabled)
return;
+ now = time(NULL);
+
rewind(file_stream);
fd = fileno(file_stream);
if (ftruncate(fd, 0) == -1)
@@ -360,7 +363,7 @@ static void Cookies_save_and_free()
/* Iterate cookies per domain, saving and freeing */
while ((node = dList_nth_data(cookies, 0))) {
for (i = 0; (cookie = dList_nth_data(node->dlist, i)); ++i) {
- if (!cookie->session_only) {
+ if (!cookie->session_only && (cookie->expires_at > now)) {
fprintf(file_stream, "%s\tTRUE\t%s\t%s\t%ld\t%s\t%s\n",
cookie->domain,
cookie->path,