summaryrefslogtreecommitdiff
path: root/sys/src/cmd/ndb/cs.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-05-01 22:17:27 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2018-05-01 22:17:27 +0200
commit8e53fe132efe25437f50974f107be4f1fcbad2ea (patch)
treee85bd07542ed4b01f9d9913110f07f22f3d8caac /sys/src/cmd/ndb/cs.c
parentbc4469e5d23509cd7f9070278b146c467d5f120a (diff)
ndb/cs: fix crash in ndbredorder due to ndbnew() not maintaining the ->line ring
we have to maintain the ->line chain for ndbreorder() to work, so add a little helper: ndbline() which replicates the ->entry chain and links the last tuple to the first; makeing the whole list into a single line.
Diffstat (limited to 'sys/src/cmd/ndb/cs.c')
-rw-r--r--sys/src/cmd/ndb/cs.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/sys/src/cmd/ndb/cs.c b/sys/src/cmd/ndb/cs.c
index a2611ee28..71e2d9e0b 100644
--- a/sys/src/cmd/ndb/cs.c
+++ b/sys/src/cmd/ndb/cs.c
@@ -1386,6 +1386,20 @@ isv4str(char *s)
return parseip(ip, s) != -1 && isv4(ip);
}
+static Ndbtuple*
+ndbline(Ndbtuple *t)
+{
+ Ndbtuple *nt;
+
+ for(nt = t; nt != nil; nt = nt->entry){
+ if(nt->entry == nil)
+ nt->line = t;
+ else
+ nt->line = nt->entry;
+ }
+ return t;
+}
+
/*
* lookup an ip destination
*/
@@ -1410,20 +1424,20 @@ iplookuphost(Network *np, char *host)
/* for dial strings with no host */
if(strcmp(host, "*") == 0)
- return ndbnew("ip", "*");
+ return ndbline(ndbnew("ip", "*"));
/*
* hack till we go v6 :: = 0.0.0.0
*/
if(strcmp("::", host) == 0)
- return ndbnew("ip", "*");
+ return ndbline(ndbnew("ip", "*"));
/*
* just accept addresses
*/
attr = ipattr(host);
if(strcmp(attr, "ip") == 0)
- return ndbnew("ip", host);
+ return ndbline(ndbnew("ip", host));
/*
* give the domain name server the first opportunity to
@@ -1627,14 +1641,8 @@ dnsip6lookup(char *mntpt, char *buf, Ndbtuple *t)
if (strcmp(tt->attr, "ipv6") == 0)
strcpy(tt->attr, "ip");
- if (t == nil)
- return t6;
-
/* append t6 list to t list */
- for (tt = t; tt->entry != nil; tt = tt->entry)
- ;
- tt->entry = t6;
- return t;
+ return ndbconcatenate(t, t6);
}
/*
@@ -1911,12 +1919,7 @@ ipinfoquery(Mfile *mf, char **list, int n)
}
/* make it all one line */
- for(nt = t; nt != nil; nt = nt->entry){
- if(nt->entry == nil)
- nt->line = t;
- else
- nt->line = nt->entry;
- }
+ t = ndbline(t);
qreply(mf, t);