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;
|
char *e;
|
||||||
|
|
||||||
e=0;
|
e=0;
|
||||||
while(strchr("\n\r\t ", *src))
|
while(*src && strchr(" \t\r\n", *src))
|
||||||
src++;
|
src++;
|
||||||
if(*src=='\'' || *src=='"'){
|
if(*src=='\'' || *src=='"'){
|
||||||
e=strrchr(src+1, *src);
|
e=strrchr(src+1, *src);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
int nbuf;
|
int nbuf;
|
||||||
char buf[64*1024+1];
|
char buf[64*1024+1];
|
||||||
char *cset = nil;
|
char *cset = nil;
|
||||||
|
char *whitespace = " \t\r\n";
|
||||||
|
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
|
@ -21,11 +22,11 @@ attr(char *s, char *a)
|
||||||
if((s = cistrstr(s, a)) == nil)
|
if((s = cistrstr(s, a)) == nil)
|
||||||
return nil;
|
return nil;
|
||||||
s += strlen(a);
|
s += strlen(a);
|
||||||
while(strchr("\r\n\t ", *s))
|
while(*s && strchr(whitespace, *s))
|
||||||
s++;
|
s++;
|
||||||
if(*s++ != '=')
|
if(*s++ != '=')
|
||||||
return nil;
|
return nil;
|
||||||
while(strchr("\r\n\t ", *s))
|
while(*s && strchr(whitespace, *s))
|
||||||
s++;
|
s++;
|
||||||
q = 0;
|
q = 0;
|
||||||
if(*s == '"' || *s == '\'')
|
if(*s == '"' || *s == '\'')
|
||||||
|
|
|
@ -67,3 +67,4 @@ struct Buq
|
||||||
int debug;
|
int debug;
|
||||||
Url *proxy;
|
Url *proxy;
|
||||||
int timeout;
|
int timeout;
|
||||||
|
char *whitespace;
|
||||||
|
|
|
@ -613,7 +613,7 @@ clientctl(Client *cl, char *ctl, char *arg)
|
||||||
else if(!strcmp(ctl, "headers")){
|
else if(!strcmp(ctl, "headers")){
|
||||||
while(arg && *arg){
|
while(arg && *arg){
|
||||||
ctl = arg;
|
ctl = arg;
|
||||||
while(*ctl && strchr("\r\n\t ", *ctl))
|
while(*ctl && strchr(whitespace, *ctl))
|
||||||
ctl++;
|
ctl++;
|
||||||
if(arg = strchr(ctl, '\n'))
|
if(arg = strchr(ctl, '\n'))
|
||||||
*arg++ = 0;
|
*arg++ = 0;
|
||||||
|
@ -663,9 +663,9 @@ fswrite(Req *r)
|
||||||
n--;
|
n--;
|
||||||
s[n] = 0;
|
s[n] = 0;
|
||||||
t = s;
|
t = s;
|
||||||
while(*t && strchr("\r\n\t ", *t)==0)
|
while(*t && strchr(whitespace, *t)==0)
|
||||||
t++;
|
t++;
|
||||||
while(*t && strchr("\r\n\t ", *t))
|
while(*t && strchr(whitespace, *t))
|
||||||
*t++ = 0;
|
*t++ = 0;
|
||||||
if(f->level == Qctl)
|
if(f->level == Qctl)
|
||||||
t = clientctl(f->client, s, t);
|
t = clientctl(f->client, s, t);
|
||||||
|
|
|
@ -274,9 +274,9 @@ hline(Hconn *h, char *data, int len, int cont)
|
||||||
if(n > 0 && cont){
|
if(n > 0 && cont){
|
||||||
e = h->buf + h->len;
|
e = h->buf + h->len;
|
||||||
for(y = x+1; y < e; y++)
|
for(y = x+1; y < e; y++)
|
||||||
if(!strchr("\t ", *y))
|
if(*y != ' ' && *y != '\t')
|
||||||
break;
|
break;
|
||||||
if(y >= e || strchr("\t ", *y))
|
if(y >= e || *y == 0)
|
||||||
break;
|
break;
|
||||||
if(y > x+1){
|
if(y > x+1){
|
||||||
if(x > h->buf && x[-1] == '\r')
|
if(x > h->buf && x[-1] == '\r')
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include "dat.h"
|
#include "dat.h"
|
||||||
#include "fns.h"
|
#include "fns.h"
|
||||||
|
|
||||||
|
char *whitespace = " \t\r\n";
|
||||||
|
|
||||||
void*
|
void*
|
||||||
emalloc(int n)
|
emalloc(int n)
|
||||||
{
|
{
|
||||||
|
@ -85,12 +87,14 @@ parsehdr(char *s)
|
||||||
{
|
{
|
||||||
char *v;
|
char *v;
|
||||||
|
|
||||||
|
if(*s == 0)
|
||||||
|
return nil;
|
||||||
v = strchr(s, 0)-1;
|
v = strchr(s, 0)-1;
|
||||||
while(v >= s && strchr("\n\r\t ", *v))
|
while(v >= s && strchr(whitespace, *v))
|
||||||
*v-- = 0;
|
*v-- = 0;
|
||||||
if(v = strchr(s, ':')){
|
if(v = strchr(s, ':')){
|
||||||
*v++ = 0;
|
*v++ = 0;
|
||||||
while(strchr("\t ", *v))
|
while(*v == ' ' || *v == '\t')
|
||||||
v++;
|
v++;
|
||||||
if(*s && *v)
|
if(*s && *v)
|
||||||
return addkey(0, s, v);
|
return addkey(0, s, v);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue