* Print answer records.
*/
sflag = (_res.pfcode & pflag);
- if (n = ntohs(cnt)) {
+ if ((n = ntohs(cnt))) {
if ((!_res.pfcode) ||
((sflag) && (_res.pfcode & RES_PRF_HEAD1)))
fprintf(file, hs);
if ((_res.options & RES_INIT) == 0 && res_init() == -1)
return;
-#define TruncTest(x) if (x >= endMark) goto trunc
+#define TruncTest(x) if (x > endMark) goto trunc
#define ErrorTest(x) if (x == NULL) goto error
/*
*/
hp = (HEADER *)msg;
cp = msg + HFIXEDSZ;
- endMark = cp + len;
+ endMark = msg + len;
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX) || hp->rcode) {
fprintf(file, ";; ->>HEADER<<- opcode: %s, status: %s, id: %d",
_res_opcodes[hp->opcode],
/*
* Print question records.
*/
- if (n = ntohs(hp->qdcount)) {
+ if ((n = ntohs(hp->qdcount))) {
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
fprintf(file, ";; QUESTIONS:\n");
while (--n >= 0) {
if ((n = dn_expand(msg, cp + msglen, cp, name, namelen)) < 0)
return (NULL);
newlen = strlen (name);
- if (newlen == 0 || name[newlen - 1] != '.')
+ if (newlen == 0 || name[newlen - 1] != '.') {
if (newlen+1 >= namelen) /* Lack space for final dot */
return (NULL);
else
strcpy(name + newlen, ".");
+ }
return (cp + n);
}
cp2 = cp1 + dlen;
while (cp < cp2) {
putc('"', file);
- if (n = (unsigned char) *cp++) {
+ if ((n = (unsigned char) *cp++)) {
for (c = n; c > 0 && cp < cp2; c--) {
if (strchr("\n\"\\", *cp))
(void) putc('\\', file);
fprintf(file, "\t%s", inet_ntop(AF_INET6, cp, t, sizeof t));
cp += dlen;
break;
- }
+ }
case T_LOC: {
char t[255];
(void) fprintf(file, "\t%s", loc_ntoa(cp, t));
cp += dlen;
break;
- }
+ }
+
+ case T_NAPTR: {
+ u_int order, preference;
+
+ order = _getshort(cp); cp += INT16SZ;
+ preference = _getshort(cp); cp += INT16SZ;
+ fprintf(file, "\t%u %u ",order, preference);
+ /* Flags */
+ n = *cp++;
+ fprintf(file,"\"%.*s\" ", (int)n, cp);
+ cp += n;
+ /* Service */
+ n = *cp++;
+ fprintf(file,"\"%.*s\" ", (int)n, cp);
+ cp += n;
+ /* Regexp */
+ n = *cp++;
+ fprintf(file,"\"%.*s\" ", (int)n, cp);
+ cp += n;
+ if ((cp = p_fqname(cp, msg, file)) == NULL)
+ return (NULL);
+ break;
+ }
case T_SRV: {
u_int priority, weight, port;
if ((cp = p_fqname(cp, msg, file)) == NULL)
return (NULL);
break;
- }
+ }
case T_MINFO:
case T_RP:
n, c);
/* orig ttl */
n = _getlong((u_char*)cp);
- if (n != tmpttl)
+ if ((u_int32_t) n != tmpttl)
fprintf(file, " %u", n);
cp += INT32SZ;
/* sig expire */
{T_UINFO, "UINFO", "user information (nonstandard)"},
{T_UID, "UID", "user ID (nonstandard)"},
{T_GID, "GID", "group ID (nonstandard)"},
+ {T_NAPTR, "NAPTR", "URN Naming Authority"},
#ifdef ALLOW_T_UNSPEC
{T_UNSPEC, "UNSPEC", "unspecified data (nonstandard)"},
#endif /* ALLOW_T_UNSPEC */
precsize_aton(strptr)
char **strptr;
{
- unsigned int mval = 0, cmval = 0;
u_int8_t retval = 0;
- register char *cp;
- register int exponent;
- register int mantissa;
+ char *cp;
+ int exponent = 0;
+ int mantissa = 0;
cp = *strptr;
+ while (isdigit(*cp)) {
+ if (mantissa == 0)
+ mantissa = *cp - '0';
+ else
+ exponent++;
+ cp++;
+ }
- while (isdigit(*cp))
- mval = mval * 10 + (*cp++ - '0');
-
- if (*cp == '.') { /* centimeters */
+ if (*cp == '.') {
cp++;
if (isdigit(*cp)) {
- cmval = (*cp++ - '0') * 10;
+ if (mantissa == 0)
+ mantissa = *cp - '0';
+ else
+ exponent++;
+ cp++;
+
if (isdigit(*cp)) {
- cmval += (*cp++ - '0');
+ if (mantissa == 0)
+ mantissa = *cp - '0';
+ else
+ exponent++;
+ cp++;
}
+ else
+ exponent++;
}
}
- cmval = (mval * 100) + cmval;
-
- for (exponent = 0; exponent < 9; exponent++)
- if (cmval < poweroften[exponent+1])
- break;
-
- mantissa = cmval / poweroften[exponent];
- if (mantissa > 9)
- mantissa = 9;
+ else
+ exponent += 2;
+ if (mantissa == 0)
+ exponent = 0;
retval = (mantissa << 4) | exponent;
-
*strptr = cp;
-
return (retval);
}
longval = (templ - ((unsigned)1<<31));
GETLONG(templ, cp);
- if (templ < referencealt) { /* below WGS 84 spheroid */
+ if (templ < (u_int32_t) referencealt) { /* below WGS 84 spheroid */
altval = referencealt - templ;
altsign = -1;
} else {