]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
resolv: Track single-request fallback via _res._flags (bug 31476)
authorFlorian Weimer <fweimer@redhat.com>
Thu, 13 Jun 2024 16:56:30 +0000 (18:56 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Wed, 24 Jul 2024 13:58:18 +0000 (15:58 +0200)
This avoids changing _res.options, which inteferes with change
detection as part of automatic reloading of /etc/resolv.conf.

Reviewed-by: DJ Delorie <dj@redhat.com>
(cherry picked from commit 868ab8923a2ec977faafec97ecafac0c3159c1b2)

NEWS
resolv/res_send.c
resolv/resolv-internal.h

diff --git a/NEWS b/NEWS
index ff11795cc0337f4ee1847feb559d749348abcef5..3aebd03acf6b9545756bdf0a1a2c946d9360d137 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -166,6 +166,7 @@ The following bugs are resolved with this release:
   [30843] potential use-after-free in getcanonname (CVE-2023-4806)
   [31184] FAIL: elf/tst-tlsgap
   [31185] Incorrect thread point access in _dl_tlsdesc_undefweak and _dl_tlsdesc_dynamic
+  [31476] resolv: Track single-request fallback via _res._flags
   [31890] resolv: Allow short error responses to match any DNS query
 
 \f
index 0aa03b697f0ef7e4ca88109f1f5af7a0651e33d0..1ee9b5208b6331d0e5f404bc90e482b52b39ea13 100644 (file)
@@ -942,9 +942,11 @@ send_dg(res_state statp,
                seconds /= statp->nscount;
        if (seconds <= 0)
                seconds = 1;
-       bool single_request_reopen = (statp->options & RES_SNGLKUPREOP) != 0;
-       bool single_request = (((statp->options & RES_SNGLKUP) != 0)
-                              | single_request_reopen);
+       bool single_request_reopen = ((statp->options & RES_SNGLKUPREOP)
+                                     || (statp->_flags & RES_F_SNGLKUPREOP));
+       bool single_request = ((statp->options & RES_SNGLKUP)
+                              || (statp->_flags & RES_F_SNGLKUP)
+                              || single_request_reopen);
        int save_gotsomewhere = *gotsomewhere;
 
        int retval;
@@ -1001,14 +1003,14 @@ send_dg(res_state statp,
                       have received the first answer.  */
                    if (!single_request)
                      {
-                       statp->options |= RES_SNGLKUP;
+                       statp->_flags |= RES_F_SNGLKUP;
                        single_request = true;
                        *gotsomewhere = save_gotsomewhere;
                        goto retry;
                      }
                    else if (!single_request_reopen)
                      {
-                       statp->options |= RES_SNGLKUPREOP;
+                       statp->_flags |= RES_F_SNGLKUPREOP;
                        single_request_reopen = true;
                        *gotsomewhere = save_gotsomewhere;
                        __res_iclose (statp, false);
index 216e47ed42076b72b39151bb506237969ddf3d01..fa92d318bab1aa4e195deef6ea005785e11eff03 100644 (file)
@@ -26,6 +26,8 @@
 #define RES_F_VC        0x00000001 /* Socket is TCP.  */
 #define RES_F_CONN      0x00000002 /* Socket is connected.  */
 #define RES_F_EDNS0ERR  0x00000004 /* EDNS0 caused errors.  */
+#define RES_F_SNGLKUP  0x00200000 /* Private version of RES_SNGLKUP.  */
+#define RES_F_SNGLKUPREOP 0x00400000 /* Private version of RES_SNGLKUPREOP.  */
 
 /* Legacy function.  This needs to be removed once all NSS modules
    have been adjusted.  */