devip: reject bad numeric ports (such as 9fs -> 9)
This commit is contained in:
parent
810aed76a5
commit
83c7a727e0
1 changed files with 15 additions and 8 deletions
|
@ -857,7 +857,11 @@ setladdrport(Conv* c, char* str, int announcing)
|
||||||
return setluniqueport(c, 0);
|
return setluniqueport(c, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
lport = atoi(p);
|
str = p;
|
||||||
|
lport = strtol(str, &p, 10);
|
||||||
|
if(p <= str || strchr("!", *p) == nil)
|
||||||
|
return "bad numeric port";
|
||||||
|
|
||||||
if(lport <= 0)
|
if(lport <= 0)
|
||||||
rv = setlport(c);
|
rv = setlport(c);
|
||||||
else
|
else
|
||||||
|
@ -874,14 +878,17 @@ setraddrport(Conv* c, char* str)
|
||||||
if(p == nil)
|
if(p == nil)
|
||||||
return "malformed address";
|
return "malformed address";
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
if (parseip(c->raddr, str) == -1)
|
if(parseip(c->raddr, str) == -1)
|
||||||
return Ebadip;
|
return Ebadip;
|
||||||
c->rport = atoi(p);
|
|
||||||
p = strchr(p, '!');
|
str = p;
|
||||||
if(p){
|
c->rport = strtol(str, &p, 10);
|
||||||
if(strstr(p, "!r") != nil)
|
if(p <= str || strchr("!", *p) == nil)
|
||||||
c->restricted = 1;
|
return "bad numeric port";
|
||||||
}
|
|
||||||
|
if(strstr(p, "!r") != nil)
|
||||||
|
c->restricted = 1;
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue