Merge pull request #2910 from rdevshp/edns0_optlen0_fix

fix OOB write in FTL_parse_pseudoheaders when optlen is 0
This commit is contained in:
Dominik
2026-06-13 17:43:29 +02:00
committed by GitHub
+5 -1
View File
@@ -369,7 +369,11 @@ void FTL_parse_pseudoheaders(unsigned char *pheader, const size_t plen)
char *pp = pretty_payload;
for(unsigned int j = 0; j < optlen; j++)
pp += sprintf(pp, "0x%02X ", payload[j]);
pretty_payload[optlen*5 - 1] = '\0'; // Truncate away the trailing whitespace
// Truncate away the trailing whitespace
if(optlen)
pretty_payload[optlen*5 - 1] = '\0';
log_debug(DEBUG_EDNS0, "CPE-ID (payload size %u): \"%s\" (%s)",
optlen, payload, pretty_payload);
free(pretty_payload);