Skip to content

Commit

Permalink
Merge branch 'bugfix/mdns_txt_alloc_issue_v4.4' into 'release/v4.4'
Browse files Browse the repository at this point in the history
mdns: Fix alloc issue if TXT has empty value

See merge request espressif/esp-idf!16889
  • Loading branch information
suren-gabrielyan-espressif committed Jan 21, 2022
2 parents 0b46ac1 + b3f913a commit 9f0a6d8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/mdns/mdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,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);
Expand Down

0 comments on commit 9f0a6d8

Please sign in to comment.