summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <hg@njw.me.uk>2011-08-03 00:42:48 +0100
committerNick White <hg@njw.me.uk>2011-08-03 00:42:48 +0100
commitdb6e6ae080819018bd17760e846fca4e85688cee (patch)
tree7563bdc2b8cfc647187554092638cdbbda76c40b
parentbbce84ba6c4b7a208bf872e553abc98ed2ecfa20 (diff)
Be more careful to fail gracefully if server replies wierdly
-rw-r--r--util.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/util.c b/util.c
index 719c8ff..6e341a5 100644
--- a/util.c
+++ b/util.c
@@ -53,7 +53,7 @@ int get(char *host, char *path, char *sendcookie, char *savecookie, char **buf)
fflush(srv);
while(h[0] != '\r') {
- fgets(h, HEADERMAX, srv);
+ 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))