Use dynamic memory for cached DNS names (#2763)

Fixes #2511
This commit is contained in:
Terry Ellison 2019-05-20 15:05:52 +01:00 committed by GitHub
parent a62db23626
commit 036bff5665
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -177,7 +177,7 @@ struct dns_table_entry {
u8_t seqno;
u8_t err;
u32_t ttl;
char name[DNS_MAX_NAME_LENGTH];
char *name;
ip_addr_t ipaddr;
/* pointer to callback on DNS query done */
dns_found_callback found;
@ -924,11 +924,14 @@ dns_enqueue(const char *name, dns_found_callback found, void *callback_arg)
LWIP_DEBUGF(DNS_DEBUG, ("dns_enqueue: \"%s\": use DNS entry %"U16_F"\n", name, (u16_t)(i)));
/* fill the entry */
namelen = LWIP_MIN(os_strlen(name), DNS_MAX_NAME_LENGTH-1);
if ((pEntry->name = (char *) mem_realloc(pEntry->name, namelen+1)) == NULL) {
return ERR_MEM;
}
pEntry->state = DNS_STATE_NEW;
pEntry->seqno = dns_seqno++;
pEntry->found = found;
pEntry->arg = callback_arg;
namelen = LWIP_MIN(os_strlen(name), DNS_MAX_NAME_LENGTH-1);
MEMCPY(pEntry->name, name, namelen);
pEntry->name[namelen] = 0;