[links-list] Re: Cookie handling bug.

Max qmax at civo.aca.nsc.ru
Fri Sep 7 12:00:40 PDT 2001


On Fri, Sep 07, 2001 at 10:31:53PM +0700, Max wrote:

>This however should be applied after my  
>cookie save/load/expiration patch available at
>ftp://ftp.civo.aca.nsc.ru/users/qmax/patches/
>
>Otherwise - ...
Oops, there are more lines from my previous patch.
Here is 'clean' space-bug fixing patch.


-------------- next part --------------
diff -ru links-0.96-0/cookies.c links-0.96/cookies.c
--- links-0.96-0/cookies.c	Wed Jun  6 23:32:50 2001
+++ links-0.96/cookies.c	Sat Sep  8 01:58:44 2001
@@ -78,14 +78,13 @@
 	struct c_server *cs;
 	unsigned char *p, *q, *s, *server, *document;
 	if (accept_cookies == ACCEPT_NONE) return 0;
-	for (p = str; *p != ';' && *p; p++) if (WHITECHAR(*p)) return 0;
-	for (q = str; *q != '='; q++) if (!*q || q >= p) return 0;
-	if (str == q || q + 1 == p) return 0;
+	p=strchr(str,'='); if( !p ) return 0;
+	q=strchr(p,';'); if( !q  ) return 0;
 	if (!(cookie = mem_alloc(sizeof(struct cookie)))) return 0;
+	cookie->name = memacpy(str, p - str);
+	cookie->value = memacpy(p + 1, q - p - 1);
 	document = get_url_data(url);
 	server = get_host_name(url);
-	cookie->name = memacpy(str, q - str);
-	cookie->value = memacpy(q + 1, p - q - 1);
 	cookie->server = stracpy(server);
 	cookie->expires = parse_header_param(str, "expires");
 	if (!(cookie->path = parse_header_param(str, "path"))) {


More information about the links-list mailing list