ref: c37de334631ca74fd7a8bccf67393b50463aaaf8
parent: 6285c19b3325e77c9056c369de1d64dd5132cb56
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Nov 3 16:38:23 EDT 2021
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.
--- a/sys/src/cmd/ndb/dblookup.c
+++ b/sys/src/cmd/ndb/dblookup.c
@@ -459,10 +459,10 @@
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++];
}
--- a/sys/src/cmd/ndb/dn.c
+++ b/sys/src/cmd/ndb/dn.c
@@ -1201,7 +1201,7 @@
* 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 @@
}
c = *data;
if(c < ' ' || c == '"' || c > '~')
- out += fmtprint(f, "\\%.3o", c);
+ out += fmtprint(f, "\\%.3d", c);
else if(c == '\\')
out += fmtprint(f, "\\\\");
else