reverse resolve does not work in /usr/lib/krb5/klookup
Reverse resolve does not work in /usr/lib/krb5/klookup:
# /usr/lib/krb5/klookup google-public-dns-a.google.com I 220.127.116.11 # /usr/lib/krb5/klookup 18.104.22.168 P #
The bug is in the following piece of code:
52 unsigned char answer[NS_MAXMSG], *ansp = NULL, *end, a, b, c, d; ... 83 case 'P': 84 rr_type = T_PTR; 85 (void) sscanf(name, "%d.%d.%d.%d", 86 &a, &b, &c, &d); 87 (void) sprintf(name, "%d.%d.%d.%d.in-addr.arpa", 88 d, c, b, a); 89 break;
The last four parameters to sscanf() are treated as pointers to int (note %d), but all four local variables (a, b, c, d) used here are defined as chars. The sscanf() function simply corrupts the contents of the local variables because of this issue.
The fix is to use %hhd instead of %d in the sscanf() format string.