From fbf3c04dbfb9cd0d6cf737f1b920eefb2ea2d5bd Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 10 Jul 2002 04:56:20 +0000 Subject: [PATCH] reviewed: bwelling 1278. [bug] libbind: res_nametotype() and res_nametoclass() were broken. --- CHANGES | 3 +++ lib/bind/resolv/res_debug.c | 34 +++++++++++++++++++++------------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/CHANGES b/CHANGES index fcfa860b0b..99e7289b71 100644 --- a/CHANGES +++ b/CHANGES @@ -31,6 +31,9 @@ 1282. [bug] ns_server_destroy() failed to set *serverp to NULL. +1278. [bug] libbind: res_nametotype() and res_nametoclass() were + broken. + 1276. [contrib] 'queryperf' now has EDNS (-e) + DNSSEC DO (-D) support. 1275. [bug] When verifying that an NXT proves nonexistence, check diff --git a/lib/bind/resolv/res_debug.c b/lib/bind/resolv/res_debug.c index 822ccf0f79..d42e42fa2d 100644 --- a/lib/bind/resolv/res_debug.c +++ b/lib/bind/resolv/res_debug.c @@ -95,7 +95,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "$Id: res_debug.c,v 1.3.2.1 2002/07/02 10:15:42 marka Exp $"; +static const char rcsid[] = "$Id: res_debug.c,v 1.3.2.2 2002/07/10 04:56:20 marka Exp $"; #endif /* LIBC_SCCS and not lint */ #include "port_before.h" @@ -1078,37 +1078,45 @@ p_secstodate (u_long secs) { } u_int16_t -res_nametoclass(const char *buf, int *success) { +res_nametoclass(const char *buf, int *successp) { unsigned long result; char *endptr; + int success; - result = sym_ston(__p_class_syms, buf, success); + result = sym_ston(__p_class_syms, buf, &success); if (success) - return (result); + goto done; if (strncasecmp(buf, "CLASS", 5) != 0 || !isdigit((unsigned char)buf[5])) - return (result); - result = strtoul(buf, &endptr, 10); + goto done; + result = strtoul(buf + 5, &endptr, 10); if (*endptr == '\0' && result <= 0xffff) - *success = 1; + success = 1; + done: + if (successp) + *successp = success; return (result); } u_int16_t -res_nametotype(const char *buf, int *success) { +res_nametotype(const char *buf, int *successp) { unsigned long result; char *endptr; + int success; - result = sym_ston(__p_type_syms, buf, success); + result = sym_ston(__p_type_syms, buf, &success); if (success) - return (result); + goto done; if (strncasecmp(buf, "type", 4) != 0 || !isdigit((unsigned char)buf[4])) - return (result); - result = strtoul(buf, &endptr, 10); + goto done; + result = strtoul(buf + 4, &endptr, 10); if (*endptr == '\0' && result <= 0xffff) - *success = 1; + success = 1; + done: + if (successp) + *successp = success; return (result); }