mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-19 13:32:21 +02:00
mdns: Fix alloc issue if TXT has empty value
* Original commit: espressif/esp-idf@205f6ba854
This commit is contained in:
committed by
suren-gabrielyan-espressif
parent
20e6e9e7fe
commit
9fdbe5f130
@ -778,8 +778,8 @@ static uint16_t _mdns_append_txt_record(uint8_t * packet, uint16_t * index, mdns
|
||||
char * tmp;
|
||||
mdns_txt_linked_item_t * txt = service->txt;
|
||||
while (txt) {
|
||||
uint8_t txt_data_len = strlen(txt->key) + txt->value_len + 1;
|
||||
tmp = (char *)malloc(txt_data_len);
|
||||
uint8_t txt_data_len = strlen(txt->key) + txt->value_len + 1 /* + '=' char */;
|
||||
tmp = (char *)malloc(txt_data_len + 1 /* + '\0' term-char in sprintf() */);
|
||||
if (tmp) {
|
||||
int offset = sprintf(tmp, "%s=", txt->key);
|
||||
memcpy(tmp + offset, txt->value, txt->value_len);
|
||||
|
Reference in New Issue
Block a user