ref: a7c01127f9749fe471367c6461cde357403cc3b3
parent: 0af11f97b582754df36b588e04fd9d9377b50823
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Feb 11 18:28:43 EST 2019
libndb: provide parseipmask() v4 argument in subnet(), use snprint() instead of sprint()
--- a/sys/src/libndb/ndbipinfo.c
+++ b/sys/src/libndb/ndbipinfo.c
@@ -120,20 +120,20 @@
subnet(Ndb *db, uchar *net, Ndbtuple *f, int prefix)
{
Ndbs s;
- Ndbtuple *t, *nt, *xt;
- char netstr[128];
+ char netstr[64];
uchar mask[IPaddrlen];
+ Ndbtuple *t, *nt, *xt;
int masklen;
t = nil;
- sprint(netstr, "%I", net);
+ snprint(netstr, sizeof(netstr), "%I", net);
nt = ndbsearch(db, &s, "ip", netstr);
while(nt != nil){
xt = ndbfindattr(nt, nt, "ipnet");
- if(xt){
+ if(xt != nil){
xt = ndbfindattr(nt, nt, "ipmask");
- if(xt)
- parseipmask(mask, xt->val);
+ if(xt != nil)
+ parseipmask(mask, xt->val, isv4(net));
else
ipmove(mask, defmask(net));
masklen = prefixlen(mask);