summaryrefslogtreecommitdiff
path: root/sys/src/cmd/ndb
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2021-11-01 14:37:19 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2021-11-01 14:37:19 +0000
commit28f67bba849d447d439b802b4d18be8169cdb54e (patch)
tree1af88a2e2211031dd901e65fd3b1b93deb2ca473 /sys/src/cmd/ndb
parent245bf71e61ec7b98af57628c86d1e65fdfc95eb5 (diff)
ndb/dns: fix ndb serialization of RR*
have todo multiple fmtprint() calls for idnname() as the buffer is shared. do not idnname() rp->os and rp->cpu, these are symbols. always quote txt= records.
Diffstat (limited to 'sys/src/cmd/ndb')
-rw-r--r--sys/src/cmd/ndb/dn.c40
1 files changed, 14 insertions, 26 deletions
diff --git a/sys/src/cmd/ndb/dn.c b/sys/src/cmd/ndb/dn.c
index c25bb19ce..8d8810293 100644
--- a/sys/src/cmd/ndb/dn.c
+++ b/sys/src/cmd/ndb/dn.c
@@ -1201,8 +1201,7 @@ int
rrfmt(Fmt *f)
{
int rv;
- char *strp;
- char buf[Domlen];
+ char *strp, buf[Domlen];
Fmt fstr;
RR *rp;
Server *s;
@@ -1333,8 +1332,8 @@ out:
int
rravfmt(Fmt *f)
{
- int rv, quote;
- char buf[Domlen], *strp;
+ int rv;
+ char *strp, buf[Domlen];
Fmt fstr;
RR *rp;
Server *s;
@@ -1357,9 +1356,7 @@ rravfmt(Fmt *f)
switch(rp->type){
case Thinfo:
- fmtprint(&fstr, " cpu=%s os=%s",
- idnname(rp->cpu, buf, sizeof(buf)),
- idnname(rp->os, buf, sizeof(buf)));
+ fmtprint(&fstr, " cpu=%s os=%s", dnname(rp->cpu), dnname(rp->os));
break;
case Tcname:
fmtprint(&fstr, " cname=%s", idnname(rp->host, buf, sizeof(buf)));
@@ -1377,9 +1374,8 @@ rravfmt(Fmt *f)
fmtprint(&fstr, " mbox=%s", idnname(rp->mb, buf, sizeof(buf)));
break;
case Tminfo:
- fmtprint(&fstr, " mbox=%s mbox=%s",
- idnname(rp->mb, buf, sizeof(buf)),
- idnname(rp->rmb, buf, sizeof(buf)));
+ fmtprint(&fstr, " mbox=%s", idnname(rp->mb, buf, sizeof(buf)));
+ fmtprint(&fstr, " mbox=%s", idnname(rp->rmb, buf, sizeof(buf)));
break;
case Tmx:
fmtprint(&fstr, " pref=%lud mx=%s", rp->pref,
@@ -1390,14 +1386,14 @@ rravfmt(Fmt *f)
fmtprint(&fstr, " ip=%s", dnname(rp->ip));
break;
case Tptr:
- fmtprint(&fstr, " dom=%s", dnname(rp->ptr));
+ fmtprint(&fstr, " dom=%s", idnname(rp->ptr, buf, sizeof(buf)));
break;
case Tsoa:
soa = rp->soa;
+ fmtprint(&fstr, " ns=%s", idnname(rp->host, buf, sizeof(buf)));
+ fmtprint(&fstr, " mbox=%s", idnname(rp->rmb, buf, sizeof(buf)));
fmtprint(&fstr,
-" ns=%s mbox=%s serial=%lud refresh=%lud retry=%lud expire=%lud ttl=%lud",
- idnname(rp->host, buf, sizeof(buf)),
- idnname(rp->rmb, buf, sizeof(buf)),
+" serial=%lud refresh=%lud retry=%lud expire=%lud ttl=%lud",
(soa? soa->serial: 0),
(soa? soa->refresh: 0), (soa? soa->retry: 0),
(soa? soa->expire: 0), (soa? soa->minttl: 0));
@@ -1418,22 +1414,14 @@ rravfmt(Fmt *f)
rp->null->data);
break;
case Ttxt:
- fmtprint(&fstr, " txt=");
- quote = 0;
- for(t = rp->txt; t != nil; t = t->next)
- if(strchr(t->p, ' '))
- quote = 1;
- if(quote)
- fmtprint(&fstr, "\"");
+ fmtprint(&fstr, " txt=\"");
for(t = rp->txt; t != nil; t = t->next)
fmtprint(&fstr, "%s", t->p);
- if(quote)
- fmtprint(&fstr, "\"");
+ fmtprint(&fstr, "\"");
break;
case Trp:
- fmtprint(&fstr, " rp=%s txt=%s",
- idnname(rp->rmb, buf, sizeof(buf)),
- idnname(rp->rp, buf, sizeof(buf)));
+ fmtprint(&fstr, " mbox=%s", idnname(rp->rmb, buf, sizeof(buf)));
+ fmtprint(&fstr, " rp=%s", idnname(rp->rp, buf, sizeof(buf)));
break;
case Tdnskey:
case Tkey: