From df8c5735b2d71374385baf288e13d6e88a17840a Mon Sep 17 00:00:00 2001 From: Nick White Date: Sun, 21 Aug 2011 17:11:43 +0100 Subject: More sscanf tightening --- util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util.c b/util.c index 6e341a5..4d2b04c 100644 --- a/util.c +++ b/util.c @@ -41,6 +41,7 @@ int get(char *host, char *path, char *sendcookie, char *savecookie, char **buf) int fd, i, p; char h[HEADERMAX] = "\0"; char c[COOKIEMAX] = ""; + char m[256]; FILE *srv; if((fd = dial(host, "80")) == -1) return 0; @@ -52,11 +53,13 @@ int get(char *host, char *path, char *sendcookie, char *savecookie, char **buf) " (not mozilla)\r\nHost: %s%s\r\n\r\n", path, host, c); fflush(srv); + snprintf(m, 256, "Set-Cookie: %%%ds;", COOKIEMAX-1); + while(h[0] != '\r') { if(!fgets(h, HEADERMAX, srv)) return 0; if(sscanf(h, "HTTP/%d.%d %d", &i, &i, &p) == 3 && p != 200) return 0; - if(savecookie != NULL && sscanf(h, "Set-Cookie: %s;", c)) + if(savecookie != NULL && sscanf(h, m, c)) strncat(savecookie, c, COOKIEMAX); } -- cgit v1.2.3