From c37de334631ca74fd7a8bccf67393b50463aaaf8 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Wed, 3 Nov 2021 20:38:23 +0000 Subject: [PATCH] ndb/dns: use decimal encoding for txt rr string escapes rfc883 suggests to use decimal digits to escape txt rr strings, and unix dig appears to use the same. so change from octal to decimal. --- sys/src/cmd/ndb/dblookup.c | 6 +++--- sys/src/cmd/ndb/dn.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/src/cmd/ndb/dblookup.c b/sys/src/cmd/ndb/dblookup.c index 0d5458778..432abc48e 100644 --- a/sys/src/cmd/ndb/dblookup.c +++ b/sys/src/cmd/ndb/dblookup.c @@ -459,10 +459,10 @@ txtrr(Ndbtuple*, Ndbtuple *pair) for(i = 0; i < n && sofar < len; i++){ uint c = pair->val[sofar++]; if(c == '\\' && sofar < len){ - if(pair->val[sofar] >= '0' && pair->val[sofar] <= '7'){ + if(pair->val[sofar] >= '0' && pair->val[sofar] <= '9'){ c = pair->val[sofar++] - '0'; - while(pair->val[sofar] >= '0' && pair->val[sofar] <= '7') - c = (c << 3) | (pair->val[sofar++] - '0'); + while(pair->val[sofar] >= '0' && pair->val[sofar] <= '9') + c = (c * 10) + (pair->val[sofar++] - '0'); } else { c = pair->val[sofar++]; } diff --git a/sys/src/cmd/ndb/dn.c b/sys/src/cmd/ndb/dn.c index 377fdd987..2fbbb50c6 100644 --- a/sys/src/cmd/ndb/dn.c +++ b/sys/src/cmd/ndb/dn.c @@ -1201,7 +1201,7 @@ idnname(DN *dn, char *buf, int nbuf) * control characters and double quotes (") which would * collide with ndb(6) format. * escape special characters by encoding them as: \DDD - * where D is a octal digit. backslash (\) is escaped + * where D is a decimal digit. backslash (\) is escaped * by doubling. valid utf8 is encoded verbatim. */ int @@ -1227,7 +1227,7 @@ bslashfmt(Fmt *f) } c = *data; if(c < ' ' || c == '"' || c > '~') - out += fmtprint(f, "\\%.3o", c); + out += fmtprint(f, "\\%.3d", c); else if(c == '\\') out += fmtprint(f, "\\\\"); else