ref: 94018b213027a9252628e107c202eefc7261073a
parent: 48d117ed648d859f407e1314effbbec56ff867ec
author: cinap_lenrek <[email protected]>
date: Mon Apr 16 21:34:10 EDT 2018
fix parseip() error handling in ipconfig, ppp, tftpfs and dns
--- a/sys/src/cmd/ip/ipconfig/main.c
+++ b/sys/src/cmd/ip/ipconfig/main.c
@@ -1715,7 +1715,8 @@
uchar ip[IPaddrlen];
if((nt = ndbfindattr(t, t, "ip")) == nil
- || parseip(ip, nt->val) < 0 || ipcmp(ip, conf.laddr) != 0){
+ || parseip(ip, nt->val) == -1
+ || ipcmp(ip, conf.laddr) != 0){
p = seprint(p, e, "\n");
for(nt = t; nt != nil; nt = nt->entry)
p = seprint(p, e, "%s=%s%s", nt->attr, nt->val,
@@ -1837,7 +1838,7 @@
ok = parseip(conf.fs+IPaddrlen*nfs++, nt->val);
else if(nauth < sizeof(conf.auth)/IPaddrlen && strcmp(nt->attr, "auth") == 0)
ok = parseip(conf.auth+IPaddrlen*nauth++, nt->val);
- if (!ok)
+ if(ok == -1)
fprint(2, "%s: bad %s address in ndb: %s\n", argv0,
nt->attr, nt->val);
}
--- a/sys/src/cmd/ip/ppp/ppp.c
+++ b/sys/src/cmd/ip/ppp/ppp.c
@@ -2901,7 +2901,8 @@
uchar ip[IPaddrlen];
if((nt = ndbfindattr(t, t, "ip")) == nil
- || parseip(ip, nt->val) < 0 || ipcmp(ip, ppp->local) != 0){
+ || parseip(ip, nt->val) == -1
+ || ipcmp(ip, ppp->local) != 0){
p = seprint(p, e, "\n");
for(nt = t; nt != nil; nt = nt->entry)
p = seprint(p, e, "%s=%s%s", nt->attr, nt->val,
--- a/sys/src/cmd/ip/tftpfs.c
+++ b/sys/src/cmd/ip/tftpfs.c
@@ -295,7 +295,7 @@
if(r->ifcall.aname && r->ifcall.aname[0]){
uchar addr[IPaddrlen];
- if(parseip(addr, r->ifcall.aname) < 0){
+ if(parseip(addr, r->ifcall.aname) == -1){
respond(r, "bad ip specified");
return;
}
@@ -459,7 +459,7 @@
case 0:
break;
case 1:
- if(parseip(ipaddr, *argv) < 0)
+ if(parseip(ipaddr, *argv) == -1)
usage();
break;
default:
--- a/sys/src/cmd/ndb/dnudpserver.c
+++ b/sys/src/cmd/ndb/dnudpserver.c
@@ -80,7 +80,7 @@
return -1;
}
tp = forwtarg + forwtcount;
- if (parseip(tp->addr, host) < 0) {
+ if(parseip(tp->addr, host) == -1) {
dnslog("can't parse ip %s", host);
return -1;
}