fix strchr \0 bugs
This commit is contained in:
parent
15885866cb
commit
55ddbff77d
6 changed files with 16 additions and 10 deletions
|
@ -243,7 +243,7 @@ char *unquot(char *dst, char *src, int len){
|
|||
char *e;
|
||||
|
||||
e=0;
|
||||
while(strchr("\n\r\t ", *src))
|
||||
while(*src && strchr(" \t\r\n", *src))
|
||||
src++;
|
||||
if(*src=='\'' || *src=='"'){
|
||||
e=strrchr(src+1, *src);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
int nbuf;
|
||||
char buf[64*1024+1];
|
||||
char *cset = nil;
|
||||
char *whitespace = " \t\r\n";
|
||||
|
||||
void
|
||||
usage(void)
|
||||
|
@ -21,11 +22,11 @@ attr(char *s, char *a)
|
|||
if((s = cistrstr(s, a)) == nil)
|
||||
return nil;
|
||||
s += strlen(a);
|
||||
while(strchr("\r\n\t ", *s))
|
||||
while(*s && strchr(whitespace, *s))
|
||||
s++;
|
||||
if(*s++ != '=')
|
||||
return nil;
|
||||
while(strchr("\r\n\t ", *s))
|
||||
while(*s && strchr(whitespace, *s))
|
||||
s++;
|
||||
q = 0;
|
||||
if(*s == '"' || *s == '\'')
|
||||
|
|
|
@ -67,3 +67,4 @@ struct Buq
|
|||
int debug;
|
||||
Url *proxy;
|
||||
int timeout;
|
||||
char *whitespace;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue