diff options
author | Nick White <git@njw.me.uk> | 2011-08-21 17:11:43 +0100 |
---|---|---|
committer | Nick White <git@njw.me.uk> | 2011-08-21 17:11:43 +0100 |
commit | df8c5735b2d71374385baf288e13d6e88a17840a (patch) | |
tree | 1d872064c5fa91a108978e0618e6af25478f2bf1 | |
parent | be77fe85042dfcc4a943c4c979ba7b990d6a124f (diff) |
More sscanf tightening
-rw-r--r-- | util.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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); } |