]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: resolvers: Fix condition to release received ARs if not assigned
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 23 Feb 2021 10:59:19 +0000 (11:59 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 24 Feb 2021 20:58:45 +0000 (21:58 +0100)
At the end of resolv_validate_dns_response(), if a received additionnal
record is not assigned to an existing server record, it is released. But the
condition to do so is buggy. If "answer_record" (the received AR) is not
assigned, "tmp_record" is not a valid record object. It is just a dummy
record "representing" the head of the record list.

Now, the condition is far cleaner. This patch must be backported as far as
2.2.

src/resolvers.c

index 6af6fc5136e7465da64a7431610db6befd5e2b62..8f2378554221056b3f43816f31f721a363fed866 100644 (file)
@@ -1238,12 +1238,14 @@ static int resolv_validate_dns_response(unsigned char *resp, unsigned char *bufe
                                        if (tmp_record->ar_item)
                                                pool_free(resolv_answer_item_pool, tmp_record->ar_item);
                                        tmp_record->ar_item = answer_record;
+                                       answer_record = NULL;
                                        break;
                                }
                        }
-                       if (tmp_record->ar_item != answer_record)
+                       if (answer_record) {
                                pool_free(resolv_answer_item_pool, answer_record);
-                       answer_record = NULL;
+                               answer_record = NULL;
+                       }
                }
        } /* for i 0 to arcount */