The branch main has been updated by des:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=cd0756cef21079104967969e275c18b84dc45053

commit cd0756cef21079104967969e275c18b84dc45053
Author:     Dag-Erling Smørgrav <d...@freebsd.org>
AuthorDate: 2025-07-24 14:01:00 +0000
Commit:     Dag-Erling Smørgrav <d...@freebsd.org>
CommitDate: 2025-07-24 14:01:00 +0000

    libc: Disable debugging code in the resolver.
    
    Reviewed by:    kevans
    Differential Revision:  https://reviews.freebsd.org/D37319
---
 lib/libc/net/gethostbydns.c    |  6 ++++++
 lib/libc/net/res_config.h      |  4 ++--
 lib/libc/resolv/res_debug.h    |  2 +-
 lib/libc/resolv/res_init.c     |  6 ------
 lib/libc/resolv/res_mkquery.c  |  5 -----
 lib/libc/resolv/res_mkupdate.c |  4 ----
 lib/libc/resolv/res_query.c    |  5 -----
 lib/libc/resolv/res_send.c     | 18 ++++++++++--------
 8 files changed, 19 insertions(+), 31 deletions(-)

diff --git a/lib/libc/net/gethostbydns.c b/lib/libc/net/gethostbydns.c
index b29fa1cdd845..216fc9bcf9a4 100644
--- a/lib/libc/net/gethostbydns.c
+++ b/lib/libc/net/gethostbydns.c
@@ -74,8 +74,10 @@
 
 #define SPRINTF(x) ((size_t)sprintf x)
 
+#ifdef DEBUG
 static const char AskedForGot[] =
                "gethostby*.gethostanswer: asked for \"%s\", got \"%s\"";
+#endif
 
 #ifdef RESOLVSORT
 static void addrsort(char **, int, res_state);
@@ -299,8 +301,10 @@ gethostanswer(const querybuf *answer, int anslen, const 
char *qname, int qtype,
                switch (type) {
                case T_PTR:
                        if (strcasecmp(tname, bp) != 0) {
+#ifdef DEBUG
                                syslog(LOG_NOTICE|LOG_AUTH,
                                       AskedForGot, qname, bp);
+#endif
                                cp += n;
                                continue;       /* XXX - had_error++ ? */
                        }
@@ -347,8 +351,10 @@ gethostanswer(const querybuf *answer, int anslen, const 
char *qname, int qtype,
                case T_A:
                case T_AAAA:
                        if (strcasecmp(he->h_name, bp) != 0) {
+#ifdef DEBUG
                                syslog(LOG_NOTICE|LOG_AUTH,
                                       AskedForGot, he->h_name, bp);
+#endif
                                cp += n;
                                continue;       /* XXX - had_error++ ? */
                        }
diff --git a/lib/libc/net/res_config.h b/lib/libc/net/res_config.h
index f049d6817b7a..39a1b5f1486f 100644
--- a/lib/libc/net/res_config.h
+++ b/lib/libc/net/res_config.h
@@ -1,5 +1,5 @@
 
-#define        DEBUG   1       /* enable debugging code (needed for dig) */
+//#define      DEBUG           /* enable debugging code */
 #define        RESOLVSORT      /* allow sorting of addresses in gethostbyname 
*/
-#undef SUNSECURITY     /* verify gethostbyaddr() calls - WE DON'T NEED IT  */
+//#define      SUNSECURITY     /* verify gethostbyaddr() calls */
 #define MULTI_PTRS_ARE_ALIASES 1 /* fold multiple PTR records into aliases */
diff --git a/lib/libc/resolv/res_debug.h b/lib/libc/resolv/res_debug.h
index dd048116fb49..ccae03e625aa 100644
--- a/lib/libc/resolv/res_debug.h
+++ b/lib/libc/resolv/res_debug.h
@@ -23,7 +23,7 @@
 #ifndef DEBUG
 #   define Dprint(cond, args) /*empty*/
 #   define DprintQ(cond, args, query, size) /*empty*/
-#   define Aerror(statp, file, string, error, address) /*empty*/
+#   define Aerror(statp, file, string, error, address, alen) /*empty*/
 #   define Perror(statp, file, string, error) /*empty*/
 #else
 #   define Dprint(cond, args) if (cond) {fprintf args;} else {}
diff --git a/lib/libc/resolv/res_init.c b/lib/libc/resolv/res_init.c
index 70d6bc6d3bf2..71ab2dcb7038 100644
--- a/lib/libc/resolv/res_init.c
+++ b/lib/libc/resolv/res_init.c
@@ -108,12 +108,6 @@
 
 #include "res_private.h"
 
-/*% Options.  Should all be left alone. */
-#define RESOLVSORT
-#ifndef        DEBUG
-#define        DEBUG
-#endif
-
 #ifdef SOLARIS2
 #include <sys/systeminfo.h>
 #endif
diff --git a/lib/libc/resolv/res_mkquery.c b/lib/libc/resolv/res_mkquery.c
index 0c15def5d117..f6767a92375c 100644
--- a/lib/libc/resolv/res_mkquery.c
+++ b/lib/libc/resolv/res_mkquery.c
@@ -76,11 +76,6 @@
 #include <string.h>
 #include "port_after.h"
 
-/* Options.  Leave them on. */
-#ifndef        DEBUG
-#define        DEBUG
-#endif
-
 extern const char *_res_opcodes[];
 
 /*%
diff --git a/lib/libc/resolv/res_mkupdate.c b/lib/libc/resolv/res_mkupdate.c
index e5a3cb702cda..3f595dc4ec08 100644
--- a/lib/libc/resolv/res_mkupdate.c
+++ b/lib/libc/resolv/res_mkupdate.c
@@ -48,10 +48,6 @@
 
 #include "port_after.h"
 
-/* Options.  Leave them on. */
-#ifndef        DEBUG
-#define        DEBUG
-#endif
 #define MAXPORT 1024
 
 static int getnum_str(u_char **, u_char *);
diff --git a/lib/libc/resolv/res_query.c b/lib/libc/resolv/res_query.c
index e9c628ad8d47..f26d59e522b4 100644
--- a/lib/libc/resolv/res_query.c
+++ b/lib/libc/resolv/res_query.c
@@ -81,11 +81,6 @@
 #include <unistd.h>
 #include "port_after.h"
 
-/* Options.  Leave them on. */
-#ifndef        DEBUG
-#define        DEBUG
-#endif
-
 #if PACKETSZ > 1024
 #define MAXPACKET      PACKETSZ
 #else
diff --git a/lib/libc/resolv/res_send.c b/lib/libc/resolv/res_send.c
index 3fb627b83d55..a68ce4f40701 100644
--- a/lib/libc/resolv/res_send.c
+++ b/lib/libc/resolv/res_send.c
@@ -112,10 +112,6 @@
 
 #include "un-namespace.h"
 
-/* Options.  Leave them on. */
-#ifndef        DEBUG
-#define        DEBUG
-#endif
 #include "res_debug.h"
 #include "res_private.h"
 
@@ -138,9 +134,11 @@ static int         send_dg(res_state,
                                const u_char *, int,
                                u_char *, int, int *, int, int,
                                int *, int *);
+#ifdef DEBUG
 static void            Aerror(const res_state, FILE *, const char *, int,
                               const struct sockaddr *, int);
 static void            Perror(const res_state, FILE *, const char *, int);
+#endif
 static int             sock_eq(struct sockaddr *, struct sockaddr *);
 #if defined(NEED_PSELECT) && !defined(USE_POLL) && !defined(USE_KQUEUE)
 static int             pselect(int, void *, void *, void *,
@@ -302,7 +300,9 @@ res_nsend(res_state statp,
 #ifdef USE_KQUEUE
        int kq;
 #endif
+#ifdef DEBUG
        char abuf[NI_MAXHOST];
+#endif
 
        /* No name servers or res_init() failure */
        if (statp->nscount == 0 || EXT(statp).ext == NULL) {
@@ -418,10 +418,10 @@ res_nsend(res_state statp,
         */
        for (tries = 0; tries < statp->retry; tries++) {
            for (ns = 0; ns < statp->nscount; ns++) {
-               struct sockaddr *nsap;
-               int nsaplen;
-               nsap = get_nsaddr(statp, ns);
-               nsaplen = get_salen(nsap);
+               struct sockaddr *nsap = get_nsaddr(statp, ns);
+#ifdef DEBUG
+               int nsaplen = get_salen(nsap);
+#endif
                statp->_flags &= ~RES_F_LASTMASK;
                statp->_flags |= (ns << RES_F_LASTSHIFT);
  same_ns:
@@ -1088,6 +1088,7 @@ send_dg(res_state statp,
        return (resplen);
 }
 
+#ifdef DEBUG
 static void
 Aerror(const res_state statp, FILE *file, const char *string, int error,
        const struct sockaddr *address, int alen)
@@ -1119,6 +1120,7 @@ Perror(const res_state statp, FILE *file, const char 
*string, int error) {
                        string, strerror(error));
        errno = save;
 }
+#endif
 
 static int
 sock_eq(struct sockaddr *a, struct sockaddr *b) {

Reply via email to