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);
|
||||
}
|
||||
|
||||
lport = atoi(p);
|
||||
str = p;
|
||||
lport = strtol(str, &p, 10);
|
||||
if(p <= str || strchr("!", *p) == nil)
|
||||
return "bad numeric port";
|
||||
|
||||
if(lport <= 0)
|
||||
rv = setlport(c);
|
||||
else
|
||||
|
@ -874,14 +878,17 @@ setraddrport(Conv* c, char* str)
|
|||
if(p == nil)
|
||||
return "malformed address";
|
||||
*p++ = 0;
|
||||
if (parseip(c->raddr, str) == -1)
|
||||
if(parseip(c->raddr, str) == -1)
|
||||
return Ebadip;
|
||||
c->rport = atoi(p);
|
||||
p = strchr(p, '!');
|
||||
if(p){
|
||||
|
||||
str = p;
|
||||
c->rport = strtol(str, &p, 10);
|
||||
if(p <= str || strchr("!", *p) == nil)
|
||||
return "bad numeric port";
|
||||
|
||||
if(strstr(p, "!r") != nil)
|
||||
c->restricted = 1;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue