diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-07-19 23:34:37 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-07-19 23:34:37 +0200 |
commit | 55ddbff77d1274c028a3be5876ca1b28e090c322 (patch) | |
tree | 0e52dab0e351ee20be31a1bcf4d5712b9e202f86 /sys/src/cmd/webfs | |
parent | 15885866cb892152519882f7d661d1dba665d712 (diff) |
fix strchr \0 bugs
Diffstat (limited to 'sys/src/cmd/webfs')
-rw-r--r-- | sys/src/cmd/webfs/dat.h | 1 | ||||
-rw-r--r-- | sys/src/cmd/webfs/fs.c | 6 | ||||
-rw-r--r-- | sys/src/cmd/webfs/http.c | 4 | ||||
-rw-r--r-- | sys/src/cmd/webfs/sub.c | 8 |
4 files changed, 12 insertions, 7 deletions
diff --git a/sys/src/cmd/webfs/dat.h b/sys/src/cmd/webfs/dat.h index 60dd0870c..b6aab58e8 100644 --- a/sys/src/cmd/webfs/dat.h +++ b/sys/src/cmd/webfs/dat.h @@ -67,3 +67,4 @@ struct Buq int debug; Url *proxy; int timeout; +char *whitespace; diff --git a/sys/src/cmd/webfs/fs.c b/sys/src/cmd/webfs/fs.c index 5e803d07d..b513ec114 100644 --- a/sys/src/cmd/webfs/fs.c +++ b/sys/src/cmd/webfs/fs.c @@ -613,7 +613,7 @@ clientctl(Client *cl, char *ctl, char *arg) else if(!strcmp(ctl, "headers")){ while(arg && *arg){ ctl = arg; - while(*ctl && strchr("\r\n\t ", *ctl)) + while(*ctl && strchr(whitespace, *ctl)) ctl++; if(arg = strchr(ctl, '\n')) *arg++ = 0; @@ -663,9 +663,9 @@ fswrite(Req *r) n--; s[n] = 0; t = s; - while(*t && strchr("\r\n\t ", *t)==0) + while(*t && strchr(whitespace, *t)==0) t++; - while(*t && strchr("\r\n\t ", *t)) + while(*t && strchr(whitespace, *t)) *t++ = 0; if(f->level == Qctl) t = clientctl(f->client, s, t); diff --git a/sys/src/cmd/webfs/http.c b/sys/src/cmd/webfs/http.c index 6562b9815..04882b138 100644 --- a/sys/src/cmd/webfs/http.c +++ b/sys/src/cmd/webfs/http.c @@ -274,9 +274,9 @@ hline(Hconn *h, char *data, int len, int cont) if(n > 0 && cont){ e = h->buf + h->len; for(y = x+1; y < e; y++) - if(!strchr("\t ", *y)) + if(*y != ' ' && *y != '\t') break; - if(y >= e || strchr("\t ", *y)) + if(y >= e || *y == 0) break; if(y > x+1){ if(x > h->buf && x[-1] == '\r') diff --git a/sys/src/cmd/webfs/sub.c b/sys/src/cmd/webfs/sub.c index b8ca1e3ac..476e5fd26 100644 --- a/sys/src/cmd/webfs/sub.c +++ b/sys/src/cmd/webfs/sub.c @@ -8,6 +8,8 @@ #include "dat.h" #include "fns.h" +char *whitespace = " \t\r\n"; + void* emalloc(int n) { @@ -85,12 +87,14 @@ parsehdr(char *s) { char *v; + if(*s == 0) + return nil; v = strchr(s, 0)-1; - while(v >= s && strchr("\n\r\t ", *v)) + while(v >= s && strchr(whitespace, *v)) *v-- = 0; if(v = strchr(s, ':')){ *v++ = 0; - while(strchr("\t ", *v)) + while(*v == ' ' || *v == '\t') v++; if(*s && *v) return addkey(0, s, v); |