mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/mdns_txt_alloc_issue' into 'master'
mdns: Fix alloc issue if TXT has empty value See merge request espressif/esp-idf!16888
This commit is contained in:
commit
faf0f61cdb
@ -778,8 +778,8 @@ static uint16_t _mdns_append_txt_record(uint8_t * packet, uint16_t * index, mdns
|
|||||||
char * tmp;
|
char * tmp;
|
||||||
mdns_txt_linked_item_t * txt = service->txt;
|
mdns_txt_linked_item_t * txt = service->txt;
|
||||||
while (txt) {
|
while (txt) {
|
||||||
uint8_t txt_data_len = strlen(txt->key) + txt->value_len + 1;
|
uint8_t txt_data_len = strlen(txt->key) + txt->value_len + 1 /* + '=' char */;
|
||||||
tmp = (char *)malloc(txt_data_len);
|
tmp = (char *)malloc(txt_data_len + 1 /* + '\0' term-char in sprintf() */);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
int offset = sprintf(tmp, "%s=", txt->key);
|
int offset = sprintf(tmp, "%s=", txt->key);
|
||||||
memcpy(tmp + offset, txt->value, txt->value_len);
|
memcpy(tmp + offset, txt->value, txt->value_len);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user