]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
addns: Move dns_domain_name_from_string() into its only calling file
authorVolker Lendecke <vl@samba.org>
Sat, 13 Jun 2026 08:51:04 +0000 (10:51 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 3 Jul 2026 08:08:36 +0000 (08:08 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/addns/dns.h
lib/addns/dnsrecord.c
lib/addns/dnsutils.c [deleted file]
lib/addns/wscript_build

index bc61b3b9d1067fb2300ec57fc9f0c45e1f5c315c..bff10db800bdf026e401465d11cf2989bb2cd302 100644 (file)
@@ -143,12 +143,6 @@ struct dns_buffer {
        DNS_ERROR error;
 };
 
-/* from dnsutils.c */
-
-DNS_ERROR dns_domain_name_from_string( TALLOC_CTX *mem_ctx,
-                                      const char *pszDomainName,
-                                      struct dns_domain_name **presult );
-
 /* from dnsrecord.c */
 
 DNS_ERROR dns_create_query( TALLOC_CTX *mem_ctx, const char *name,
index e5fe07158413a69015a78d2ca0aa58644424182f..8b9793b4829bc5db712ee15460518f7c5afc0429 100644 (file)
 #include "dns.h"
 #include "lib/util/genrand.h"
 
+static DNS_ERROR LabelList( TALLOC_CTX *mem_ctx,
+                           const char *name,
+                           struct dns_domain_label **presult )
+{
+       struct dns_domain_label *result;
+       const char *dot;
+
+       for (dot = name; *dot != '\0'; dot += 1) {
+               char c = *dot;
+
+               if (c == '.')
+                       break;
+
+               if (c == '-') continue;
+               if ((c >= 'a') && (c <= 'z')) continue;
+               if ((c >= 'A') && (c <= 'Z')) continue;
+               if ((c >= '0') && (c <= '9')) continue;
+
+               return ERROR_DNS_INVALID_NAME;
+       }
+
+       if ((dot - name) > 63) {
+               /*
+                * DNS labels can only be 63 chars long
+                */
+               return ERROR_DNS_INVALID_NAME;
+       }
+
+       if (!(result = talloc_zero(mem_ctx, struct dns_domain_label))) {
+               return ERROR_DNS_NO_MEMORY;
+       }
+
+       if (*dot == '\0') {
+               /*
+                * No dot around, so this is the last component
+                */
+
+               if (!(result->label = talloc_strdup(result, name))) {
+                       TALLOC_FREE(result);
+                       return ERROR_DNS_NO_MEMORY;
+               }
+               result->len = strlen(result->label);
+               *presult = result;
+               return ERROR_DNS_SUCCESS;
+       }
+
+       if (dot[1] == '.') {
+               /*
+                * Two dots in a row, reject
+                */
+
+               TALLOC_FREE(result);
+               return ERROR_DNS_INVALID_NAME;
+       }
+
+       if (dot[1] != '\0') {
+               /*
+                * Something follows, get the rest
+                */
+
+               DNS_ERROR err = LabelList(result, dot+1, &result->next);
+
+               if (!ERR_DNS_IS_OK(err)) {
+                       TALLOC_FREE(result);
+                       return err;
+               }
+       }
+
+       result->len = (dot - name);
+
+       if (!(result->label = talloc_strndup(result, name, result->len))) {
+               TALLOC_FREE(result);
+               return ERROR_DNS_NO_MEMORY;
+       }
+
+       *presult = result;
+       return ERROR_DNS_SUCCESS;
+}
+
+static DNS_ERROR dns_domain_name_from_string( TALLOC_CTX *mem_ctx,
+                                      const char *pszDomainName,
+                                      struct dns_domain_name **presult )
+{
+       struct dns_domain_name *result;
+       DNS_ERROR err;
+
+       if (!(result = talloc(mem_ctx, struct dns_domain_name))) {
+               return ERROR_DNS_NO_MEMORY;
+       }
+
+       err = LabelList( result, pszDomainName, &result->pLabelList );
+       if (!ERR_DNS_IS_OK(err)) {
+               TALLOC_FREE(result);
+               return err;
+       }
+
+       *presult = result;
+       return ERROR_DNS_SUCCESS;
+}
+
 DNS_ERROR dns_create_query( TALLOC_CTX *mem_ctx, const char *name,
                            uint16_t q_type, uint16_t q_class,
                            struct dns_request **preq )
diff --git a/lib/addns/dnsutils.c b/lib/addns/dnsutils.c
deleted file mode 100644 (file)
index 53401eb..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
-  Linux DNS client library implementation
-
-  Copyright (C) 2006 Krishna Ganugapati <krishnag@centeris.com>
-  Copyright (C) 2006 Gerald Carter <jerry@samba.org>
-
-     ** NOTE! The following LGPL license applies to the libaddns
-     ** library. This does NOT imply that all of Samba is released
-     ** under the LGPL
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "librpc/ndr/libndr.h"
-#include "librpc/gen_ndr/ndr_misc.h"
-
-#include "dns.h"
-#include <ctype.h>
-
-
-static DNS_ERROR LabelList( TALLOC_CTX *mem_ctx,
-                           const char *name,
-                           struct dns_domain_label **presult )
-{
-       struct dns_domain_label *result;
-       const char *dot;
-
-       for (dot = name; *dot != '\0'; dot += 1) {
-               char c = *dot;
-
-               if (c == '.')
-                       break;
-
-               if (c == '-') continue;
-               if ((c >= 'a') && (c <= 'z')) continue;
-               if ((c >= 'A') && (c <= 'Z')) continue;
-               if ((c >= '0') && (c <= '9')) continue;
-
-               return ERROR_DNS_INVALID_NAME;
-       }
-
-       if ((dot - name) > 63) {
-               /*
-                * DNS labels can only be 63 chars long
-                */
-               return ERROR_DNS_INVALID_NAME;
-       }
-
-       if (!(result = talloc_zero(mem_ctx, struct dns_domain_label))) {
-               return ERROR_DNS_NO_MEMORY;
-       }
-
-       if (*dot == '\0') {
-               /*
-                * No dot around, so this is the last component
-                */
-
-               if (!(result->label = talloc_strdup(result, name))) {
-                       TALLOC_FREE(result);
-                       return ERROR_DNS_NO_MEMORY;
-               }
-               result->len = strlen(result->label);
-               *presult = result;
-               return ERROR_DNS_SUCCESS;
-       }
-
-       if (dot[1] == '.') {
-               /*
-                * Two dots in a row, reject
-                */
-
-               TALLOC_FREE(result);
-               return ERROR_DNS_INVALID_NAME;
-       }
-
-       if (dot[1] != '\0') {
-               /*
-                * Something follows, get the rest
-                */
-
-               DNS_ERROR err = LabelList(result, dot+1, &result->next);
-
-               if (!ERR_DNS_IS_OK(err)) {
-                       TALLOC_FREE(result);
-                       return err;
-               }
-       }
-
-       result->len = (dot - name);
-
-       if (!(result->label = talloc_strndup(result, name, result->len))) {
-               TALLOC_FREE(result);
-               return ERROR_DNS_NO_MEMORY;
-       }
-
-       *presult = result;
-       return ERROR_DNS_SUCCESS;
-}
-
-DNS_ERROR dns_domain_name_from_string( TALLOC_CTX *mem_ctx,
-                                      const char *pszDomainName,
-                                      struct dns_domain_name **presult )
-{
-       struct dns_domain_name *result;
-       DNS_ERROR err;
-
-       if (!(result = talloc(mem_ctx, struct dns_domain_name))) {
-               return ERROR_DNS_NO_MEMORY;
-       }
-
-       err = LabelList( result, pszDomainName, &result->pLabelList );
-       if (!ERR_DNS_IS_OK(err)) {
-               TALLOC_FREE(result);
-               return err;
-       }
-
-       *presult = result;
-       return ERROR_DNS_SUCCESS;
-}
index 694d71b732e1abc54d7868a5fca49b90eb7855bf..d6ad5952c2b4a691e2317934e8750321342a4cd1 100644 (file)
@@ -4,7 +4,6 @@ bld.SAMBA_LIBRARY('addns',
                    source='''
                        dnsquery.c
                        dnsrecord.c
-                       dnsutils.c
                        dnssock.c
                        dnsgss.c
                        dnsmarshall.c