]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: dns: add test on result getting value from buffer into ring.
authorEmeric Brun <ebrun@haproxy.com>
Mon, 15 Feb 2021 12:58:06 +0000 (13:58 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 15 Feb 2021 14:12:55 +0000 (15:12 +0100)
This patch adds a missing test in dns_session_io_handler, getting
the query id from the buffer of the ring. An error should never
happen since messages are completely added atomically.

This bug should fix github issue #1133

src/dns.c

index 352e88c9aa05411d4c1a00ab6bdf2084feae476a..bc40b29e808042f32333b2f11969685116b1be6e 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -522,6 +522,13 @@ static void dns_session_io_handler(struct appctx *appctx)
 
                                /* backup original query id */
                                len = b_getblk(buf, (char *)&original_qid, sizeof(original_qid), ofs + cnt);
+                               if (!len) {
+                                       /* should never happen since messages are atomically
+                                        * written into ring
+                                        */
+                                       ret = 0;
+                                       break;
+                               }
 
                                /* generates new query id */
                                new_qid = ++ds->query_counter;