Skip to content

Cast the original rcode to (dns_ttl_t) when setting extended rcode

Shifting (signed) integer left could trigger undefined behaviour when the shifted value would overflow into the sign bit (e.g. 2048).

The issue was found when using AFL++ and UBSAN:

message.c:2274:33: runtime error: left shift of 2048 by 20 places cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior message.c:2274:33 in

(cherry picked from commit a3476417)

Closes #2095 (closed)

Merge request reports