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 188.8.131.52 # /usr/lib/krb5/klookup 184.108.40.206 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.
Updated by Electric Monk about 7 years ago
- Status changed from Pending RTI to Closed
- % Done changed from 0 to 100
commit 9c62f9ec8ed42265fb80cb8d6873fabfae3941ab Author: Marcel Telka <email@example.com> Date: 2014-07-09T17:07:49.000Z 4985 reverse resolve does not work in /usr/lib/krb5/klookup Reviewed by: Gordon Ross <firstname.lastname@example.org> Reviewed by: Dan McDonald <email@example.com> Reviewed by: Garrett D'Amore <firstname.lastname@example.org> Approved by: Richard Lowe <email@example.com>