Skip to content

Commit e6f179d

Browse files
tpambordkalowsk
authored andcommitted
tests: net: dns-sd: Fix undefined behavior reported by UBSAN
htons() takes uint16_t as argument. Add the 'u' suffix to the TTL constants to ensure the correct unsigned type is used and to avoid undefined behavior if these functions are implemented as macros using bit shifts. Signed-off-by: Tim Pambor <[email protected]>
1 parent 659382f commit e6f179d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

subsys/net/lib/dns/dns_sd.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
#include "dns_pack.h"
1919

2020
/* TODO: Move these into Kconfig */
21-
#define DNS_SD_PTR_TTL 4500
22-
#define DNS_SD_TXT_TTL 4500
23-
#define DNS_SD_SRV_TTL 120
24-
#define DNS_SD_A_TTL 120
25-
#define DNS_SD_AAAA_TTL 120
21+
#define DNS_SD_PTR_TTL 4500u
22+
#define DNS_SD_TXT_TTL 4500u
23+
#define DNS_SD_SRV_TTL 120u
24+
#define DNS_SD_A_TTL 120u
25+
#define DNS_SD_AAAA_TTL 120u
2626

2727
#define DNS_SD_PTR_MASK (NS_CMPRSFLGS << 8)
2828

0 commit comments

Comments
 (0)