From: Michał Kępień Date: Mon, 5 Mar 2018 13:13:52 +0000 (+0100) Subject: Replace getquad() with inet_pton() X-Git-Tag: v9.13.0~120^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4f96cebce3400f65f3963208657051f11ec75cc6;p=thirdparty%2Fbind9.git Replace getquad() with inet_pton() getquad() was implemented back in 2001 to warn about IPv4 addresses in non-dotted-quad form being used. As change 4900 (GL #13) removed all uses of inet_aton(), which allowed such forms, with inet_pton(), which does not allow them, there is no point in keeping getquad() around as it now only prints an extra warning when the parser comes across an IP address in a form which is not acceptable anyway. Replace all uses of getquad() with inet_pton(AF_INET, ...). --- diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index e72b49909a4..3788c6ce19b 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -378,24 +378,6 @@ locator_pton(const char *src, unsigned char *dst) { return (1); } -static inline int -getquad(const void *src, struct in_addr *dst, - isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks) -{ - int result; - - result = inet_pton(AF_INET, src, dst); - if (result != 1 && callbacks != NULL) { - const char *name = isc_lex_getsourcename(lexer); - if (name == NULL) - name = "UNKNOWN"; - (*callbacks->warn)(callbacks, "%s:%lu: \"%s\" " - "is not a decimal dotted quad", name, - isc_lex_getsourceline(lexer), src); - } - return (result); -} - static inline isc_result_t name_duporclone(const dns_name_t *source, isc_mem_t *mctx, dns_name_t *target) { diff --git a/lib/dns/rdata/generic/ipseckey_45.c b/lib/dns/rdata/generic/ipseckey_45.c index 1f5acd4c255..040299d2f62 100644 --- a/lib/dns/rdata/generic/ipseckey_45.c +++ b/lib/dns/rdata/generic/ipseckey_45.c @@ -77,7 +77,7 @@ fromtext_ipseckey(ARGS_FROMTEXT) { break; case 1: - if (getquad(DNS_AS_STR(token), &addr, lexer, callbacks) != 1) + if (inet_pton(AF_INET, DNS_AS_STR(token), &addr) != 1) RETTOK(DNS_R_BADDOTTEDQUAD); isc_buffer_availableregion(target, ®ion); if (region.length < 4) diff --git a/lib/dns/rdata/generic/l32_105.c b/lib/dns/rdata/generic/l32_105.c index 9ae90c4395d..6332131e597 100644 --- a/lib/dns/rdata/generic/l32_105.c +++ b/lib/dns/rdata/generic/l32_105.c @@ -41,7 +41,7 @@ fromtext_l32(ARGS_FROMTEXT) { RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); - if (getquad(DNS_AS_STR(token), &addr, lexer, callbacks) != 1) + if (inet_pton(AF_INET, DNS_AS_STR(token), &addr) != 1) RETTOK(DNS_R_BADDOTTEDQUAD); isc_buffer_availableregion(target, ®ion); if (region.length < 4) diff --git a/lib/dns/rdata/hs_4/a_1.c b/lib/dns/rdata/hs_4/a_1.c index 6887c81e492..358992249b2 100644 --- a/lib/dns/rdata/hs_4/a_1.c +++ b/lib/dns/rdata/hs_4/a_1.c @@ -33,11 +33,12 @@ fromtext_hs_a(ARGS_FROMTEXT) { UNUSED(origin); UNUSED(options); UNUSED(rdclass); + UNUSED(callbacks); RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); - if (getquad(DNS_AS_STR(token), &addr, lexer, callbacks) != 1) + if (inet_pton(AF_INET, DNS_AS_STR(token), &addr) != 1) RETTOK(DNS_R_BADDOTTEDQUAD); isc_buffer_availableregion(target, ®ion); if (region.length < 4) diff --git a/lib/dns/rdata/in_1/a_1.c b/lib/dns/rdata/in_1/a_1.c index 89de1960545..6c2356ffe3f 100644 --- a/lib/dns/rdata/in_1/a_1.c +++ b/lib/dns/rdata/in_1/a_1.c @@ -35,11 +35,12 @@ fromtext_in_a(ARGS_FROMTEXT) { UNUSED(origin); UNUSED(options); UNUSED(rdclass); + UNUSED(callbacks); RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); - if (getquad(DNS_AS_STR(token), &addr, lexer, callbacks) != 1) + if (inet_pton(AF_INET, DNS_AS_STR(token), &addr) != 1) RETTOK(DNS_R_BADDOTTEDQUAD); isc_buffer_availableregion(target, ®ion); if (region.length < 4) diff --git a/lib/dns/rdata/in_1/wks_11.c b/lib/dns/rdata/in_1/wks_11.c index ac247118117..cb3abd00c23 100644 --- a/lib/dns/rdata/in_1/wks_11.c +++ b/lib/dns/rdata/in_1/wks_11.c @@ -93,6 +93,7 @@ fromtext_in_wks(ARGS_FROMTEXT) { UNUSED(origin); UNUSED(options); UNUSED(rdclass); + UNUSED(callbacks); RUNTIME_CHECK(isc_once_do(&once, init_lock) == ISC_R_SUCCESS); @@ -117,7 +118,7 @@ fromtext_in_wks(ARGS_FROMTEXT) { ISC_FALSE)); isc_buffer_availableregion(target, ®ion); - if (getquad(DNS_AS_STR(token), &addr, lexer, callbacks) != 1) + if (inet_pton(AF_INET, DNS_AS_STR(token), &addr) != 1) CHECKTOK(DNS_R_BADDOTTEDQUAD); if (region.length < 4) return (ISC_R_NOSPACE);