Blame SOURCES/0011-avahi_dns_packet_consume_uint32-fix-potential-undefi.patch

a1aaf5
From b897ca43ac100d326d118e5877da710eb7f836f9 Mon Sep 17 00:00:00 2001
a1aaf5
From: traffic-millions <60914101+traffic-millions@users.noreply.github.com>
a1aaf5
Date: Tue, 3 Mar 2020 11:15:48 +0800
a1aaf5
Subject: [PATCH 11/11] avahi_dns_packet_consume_uint32: fix potential
a1aaf5
 undefined behavior
a1aaf5
a1aaf5
avahi_dns_packet_consume_uint32 left shifts uint8_t values by 8, 16 and 24 bits to combine them into a 32-bit value. This produces an undefined behavior warning with gcc -fsanitize when fed input values of 128 or 255 however in testing no actual unexpected behavior occurs in practice and the 32-bit uint32_t is always correctly produced as the final value is immediately stored into a uint32_t and the compiler appears to handle this "correctly".
a1aaf5
a1aaf5
Cast the intermediate values to uint32_t to prevent this warning and ensure the intended result is explicit.
a1aaf5
a1aaf5
Closes: #267
a1aaf5
Closes: #268
a1aaf5
Reference: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19304
a1aaf5
---
a1aaf5
 avahi-core/dns.c | 2 +-
a1aaf5
 1 file changed, 1 insertion(+), 1 deletion(-)
a1aaf5
a1aaf5
diff --git a/avahi-core/dns.c b/avahi-core/dns.c
a1aaf5
index 7c38f42..d793b76 100644
a1aaf5
--- a/avahi-core/dns.c
a1aaf5
+++ b/avahi-core/dns.c
a1aaf5
@@ -455,7 +455,7 @@ int avahi_dns_packet_consume_uint32(AvahiDnsPacket *p, uint32_t *ret_v) {
a1aaf5
         return -1;
a1aaf5
 
a1aaf5
     d = (uint8_t*) (AVAHI_DNS_PACKET_DATA(p) + p->rindex);
a1aaf5
-    *ret_v = (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | d[3];
a1aaf5
+    *ret_v = ((uint32_t)d[0] << 24) | ((uint32_t)d[1] << 16) | ((uint32_t)d[2] << 8) | (uint32_t)d[3];
a1aaf5
     p->rindex += sizeof(uint32_t);
a1aaf5
 
a1aaf5
     return 0;
a1aaf5
-- 
a1aaf5
2.25.2
a1aaf5