]> code.citadel.org Git - citadel.git/blobdiff - webcit/context_loop.c
Fixed the webcit preferences bug once and for all, using a proper
[citadel.git] / webcit / context_loop.c
index 032c82a603399aa453a5b8d07e04af46054c54bb..b7d556c50a4fdea202b6444ef7e162c1161d846e 100644 (file)
@@ -92,8 +92,13 @@ void do_housekeeping(void)
                pthread_mutex_lock(&sessions_to_kill->SessionMutex);
                close(sessions_to_kill->serv_sock);
                close(sessions_to_kill->chat_sock);
-               if (sessions_to_kill->preferences != NULL) {
-                       free(sessions_to_kill->preferences);
+               while (sessions_to_kill->first_pref != NULL) {
+                       struct wcpref *ptr;
+                       ptr = sessions_to_kill->first_pref->next;
+                       free(sessions_to_kill->first_pref->pref_key);
+                       free(sessions_to_kill->first_pref->pref_value);
+                       free(sessions_to_kill->first_pref);
+                       sessions_to_kill->first_pref = ptr;
                }
                if (sessions_to_kill->cache_fold != NULL) {
                        free(sessions_to_kill->cache_fold);
@@ -157,7 +162,7 @@ int GenerateSessionID(void)
 /*
  * Collapse multiple cookies on one line
  */
-int req_gets(int sock, char *buf, char *hold)
+int req_gets(int sock, char *buf, char *hold, size_t hlen)
 {
        int a, b;
 
@@ -177,7 +182,7 @@ int req_gets(int sock, char *buf, char *hold)
                        if (buf[a] == ';') {
                                // we don't refresh len, because of we 
                                // only exit from here.
-                               sprintf(hold, "Cookie: %s", &buf[a + 1]);
+                               snprintf(hold, hlen, "Cookie: %s", &buf[a + 1]);
                                buf[a] = 0;
                                b = 8;
                                while (isspace(hold[b]))
@@ -303,7 +308,7 @@ void context_loop(int sock)
         */
        memset(hold, 0, sizeof(hold));
        do {
-               if (req_gets(sock, buf, hold) < 0) return;
+               if (req_gets(sock, buf, hold, SIZ) < 0) return;
 
                /**
                 * Can we compress?