]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Replace getquad() with inet_pton()
authorMichał Kępień <michal@isc.org>
Mon, 5 Mar 2018 13:13:52 +0000 (14:13 +0100)
committerMichał Kępień <michal@isc.org>
Tue, 6 Mar 2018 08:49:30 +0000 (09:49 +0100)
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, ...).

lib/dns/rdata.c
lib/dns/rdata/generic/ipseckey_45.c
lib/dns/rdata/generic/l32_105.c
lib/dns/rdata/hs_4/a_1.c
lib/dns/rdata/in_1/a_1.c
lib/dns/rdata/in_1/wks_11.c

index e72b49909a44633f0d9e3e4b74b06ba07ea1e471..3788c6ce19b4fc9ebf43a4675017978856513f0e 100644 (file)
@@ -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) {
 
index 1f5acd4c2555ef28ef16e0f70c213da4c9b9ec46..040299d2f62bd2fcea47773ea40cc16e11f9c973 100644 (file)
@@ -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, &region);
                if (region.length < 4)
index 9ae90c4395d71bec7baa18e7acf750997b383105..6332131e597a75d195a1bf89a0aecf4f89d02c4d 100644 (file)
@@ -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, &region);
        if (region.length < 4)
index 6887c81e49254cbea42aa84a0a80aa55e1175d17..358992249b280837a2123f31ff79e9c5f1fb6198 100644 (file)
@@ -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, &region);
        if (region.length < 4)
index 89de196054567bc12c5dc334a5796180b071dd92..6c2356ffe3f3d4a331cafe07649139ae38df005e 100644 (file)
@@ -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, &region);
        if (region.length < 4)
index ac2471181178ed233d990cd3dbdebba71f2c226c..cb3abd00c2371edf2b71dabaef0e3d5e9132c1ae 100644 (file)
@@ -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, &region);
-       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);