]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
Revert "BUG/MEDIUM: dns: fix long loops in additional records parse on name failure"
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 27 May 2026 13:37:35 +0000 (15:37 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 27 May 2026 13:42:10 +0000 (15:42 +0200)
This reverts commit fefce297ab5d0c36d6d6773092c976ea6166dc1e.

The commit broke the resolvers. All responses are marked as invalid. The
resolv_read_name() function can return 0 on error, but it seems also
possible to return 0 when no label name was found. And depending on the
caller, it can be an error... or not.

So, let's revert it. This might trigger a watchdog but doesn't seem to and
once fixed it makes things worse.

Must be backported as far as 2.4.

src/resolvers.c

index ffdc3163c4e00acdba83271494957bbfd1981107..bb07ae566987af8447ef82d3778735a52dfd959b 100644 (file)
@@ -1420,7 +1420,7 @@ static int resolv_validate_dns_response(unsigned char *resp, unsigned char *bufe
                len = resolv_read_name(resp, bufend, reader, tmpname, DNS_MAX_NAME_SIZE,
                                    &offset, 0);
                if (len == 0)
-                       goto invalid_resp;
+                       continue;
 
                if (reader + offset + 10 > bufend)
                        goto invalid_resp;
@@ -1456,8 +1456,11 @@ static int resolv_validate_dns_response(unsigned char *resp, unsigned char *bufe
                offset = 0;
                len = resolv_read_name(resp, bufend, reader, tmpname, DNS_MAX_NAME_SIZE, &offset, 0);
 
-               if (len == 0)
-                       goto invalid_resp;
+               if (len == 0) {
+                       pool_free(resolv_answer_item_pool, answer_record);
+                       answer_record = NULL;
+                       continue;
+               }
 
                memcpy(answer_record->name, tmpname, len);
                answer_record->name[len] = 0;