BUG/MINOR: dns: Make dns_query_id_seed unsigned

Left shifting of large signed values and negative values is undefined.

In a test script clang's ubsan rightfully complains:

> runtime error: left shift of 1934242336581872173 by 13 places cannot be represented in type 'int64_t' (aka 'long')

This bug was introduced in the initial version of the DNS resolver
in 325137d603. The fix must be backported
to HAProxy 1.6+.
This commit is contained in:
Tim Duesterhus 2020-01-18 02:04:12 +01:00 committed by Willy Tarreau
parent d34b1ce5a2
commit fcac33d0c1
1 changed files with 1 additions and 1 deletions

View File

@ -54,7 +54,7 @@
struct list dns_resolvers = LIST_HEAD_INIT(dns_resolvers); struct list dns_resolvers = LIST_HEAD_INIT(dns_resolvers);
struct list dns_srvrq_list = LIST_HEAD_INIT(dns_srvrq_list); struct list dns_srvrq_list = LIST_HEAD_INIT(dns_srvrq_list);
static THREAD_LOCAL int64_t dns_query_id_seed = 0; /* random seed */ static THREAD_LOCAL uint64_t dns_query_id_seed = 0; /* random seed */
DECLARE_STATIC_POOL(dns_answer_item_pool, "dns_answer_item", sizeof(struct dns_answer_item)); DECLARE_STATIC_POOL(dns_answer_item_pool, "dns_answer_item", sizeof(struct dns_answer_item));
DECLARE_STATIC_POOL(dns_resolution_pool, "dns_resolution", sizeof(struct dns_resolution)); DECLARE_STATIC_POOL(dns_resolution_pool, "dns_resolution", sizeof(struct dns_resolution));