diff -ruN ./0.7/config.h ./0.8/config.h --- ./0.7/config.h Thu May 16 17:36:39 2002 +++ ./0.8/config.h Wed Jun 5 13:43:53 2002 @@ -1,2 +1,2 @@ #define TCP_PORT 8080 -#define VERSION "0.7" +#define VERSION "0.8" diff -ruN ./0.7/connection.c ./0.8/connection.c --- ./0.7/connection.c Fri May 17 18:58:29 2002 +++ ./0.8/connection.c Wed Jun 5 13:42:21 2002 @@ -315,8 +315,9 @@ q++; } c_server_id[q-1] = '\0'; - if (line[q] != '?') - BAIL_OUT; + + if (line[q] != '?' && isalnum(line[q])) + BAIL_OUT_EXIT; tmp_server_id = strtol(c_server_id, NULL, 10); connection->server_id = (int)tmp_server_id; len = (int) strlen(line); @@ -413,9 +414,11 @@ if ( (tmp_ptr = strchr(line_ptr,'=')) ){ tmp_ptr++; while(isspace(*tmp_ptr)) tmp_ptr++; - got_S_cookie = 1; - strncpy(S_cookie, tmp_ptr, 1024); - DEBUG("got S cookie\n"); + if (N == connection->server_id){ + got_S_cookie = 1; + strncpy(S_cookie, tmp_ptr, 1024); + DEBUG("got S cookie\n"); + } } } } /* is valid cookie */ @@ -433,8 +436,12 @@ } /* make action according to received cookies */ + /* these conditions should be written in more optimal way, but I leave it + * this way, to be more readable and obvious + */ N = connection->server_id; - if ( (got_V_cookie && !got_S_cookie) || (!got_V_cookie && !got_S_cookie) ){ + if ( (got_V_cookie && !got_S_cookie) || (!got_V_cookie && !got_S_cookie) + || (got_S_cookie && !got_V_cookie)){ /* we need to create new item - only setting of first_visit_flag * differs from case to case (we know from got_V_cookie) */ @@ -443,8 +450,8 @@ connection->do_set_cookie = 1; connection->set_cookie = get_identifier( connection->server_id, time(NULL)); - fprintf(stderr,"creating new session, with first_visit_flag = 0, id = %s\n", - connection->set_cookie); + fprintf(stderr,"creating new session, id: %ld, with first_visit_flag = 0, id = %s\n", + N, connection->set_cookie); add_new_item(N, time(NULL), connection->set_cookie, got_V_cookie, (char *)strdup(connection->ip_addr)); } @@ -568,8 +575,8 @@ DOMAIN_NAME); write(socket, write_buffer, strlen(write_buffer)); /* V cookie */ - snprintf (write_buffer, MAX_WRITE_BUFFER_SIZE, "Set-cookie: V%d = YES; expires = %s; domain = %s; PATH = /\r\n\r\n", - connection->server_id, expiry_time, DOMAIN_NAME); + snprintf (write_buffer, MAX_WRITE_BUFFER_SIZE, "Set-cookie: V%d = YES; expires = Mon, 01 Jan 3000 01:01:01 +0200; domain = %s; PATH = /\r\n\r\n", + connection->server_id, DOMAIN_NAME); write(socket, write_buffer, strlen(write_buffer)); }