ref: 45213ee6c72347fd31dc2d999742f632d508a132
parent: d551a83ae4e3e42c4d7da9638ec1f937200844cb
author: cinap_lenrek <[email protected]>
date: Tue Feb 12 16:44:57 EST 2019
ip/ipconfig, ndb/dns, libndb: handle parseipmask() errors
--- a/sys/src/cmd/ip/ipconfig/main.c
+++ b/sys/src/cmd/ip/ipconfig/main.c
@@ -1019,12 +1019,13 @@
}
if(strcmp(nt->attr, "ipmask") == 0) {
nt = uniquent(nt);
- parseipmask(conf.mask, nt->val, isv4(myip));
+ if(parseipmask(conf.mask, nt->val, isv4(myip)) == -1)
+ goto Badip;
continue;
}
if(parseip(ip, nt->val) == -1) {
- fprint(2, "%s: bad %s address in ndb: %s\n", argv0,
- nt->attr, nt->val);
+ Badip:
+ fprint(2, "%s: bad %s address in ndb: %s\n", argv0, nt->attr, nt->val);
continue;
}
if(strcmp(nt->attr, "ipgw") == 0) {
--- a/sys/src/cmd/ndb/dblookup.c
+++ b/sys/src/cmd/ndb/dblookup.c
@@ -1062,11 +1062,10 @@
if(t == nil) /* could be a reverse with no forward */
continue;
nt = look(t, t, "ipmask");
- if(nt == nil){ /* we're confused */
+ if(nt == nil || parseipmask(mask, nt->val, 1) == -1){
ndbfree(t);
continue;
}
- parseipmask(mask, nt->val, 1);
ndbfree(t);
n = 5;
break;
--- a/sys/src/libndb/ndbipinfo.c
+++ b/sys/src/libndb/ndbipinfo.c
@@ -123,7 +123,6 @@
char netstr[64];
uchar mask[IPaddrlen];
Ndbtuple *t, *nt, *xt;
- int masklen;
t = nil;
snprint(netstr, sizeof(netstr), "%I", net);
@@ -132,12 +131,9 @@
xt = ndbfindattr(nt, nt, "ipnet");
if(xt != nil){
xt = ndbfindattr(nt, nt, "ipmask");
- if(xt != nil)
- parseipmask(mask, xt->val, isv4(net));
- else
+ if(xt == nil || parseipmask(mask, xt->val, isv4(net)) == -1)
ipmove(mask, defmask(net));
- masklen = prefixlen(mask);
- if(masklen <= prefix){
+ if(prefixlen(mask) <= prefix){
t = ndbconcatenate(t, filter(db, nt, f));
nt = nil;
}