Added missing casts, use strlen + MEMCPY instead of strcpy (as that might overrun the buffer)

This commit is contained in:
goldsimon 2010-03-16 15:14:14 +00:00
parent 7466474365
commit a54bb7205d
2 changed files with 6 additions and 3 deletions

View File

@ -310,7 +310,7 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
/* If this fails, please report to lwip-devel! :-) */
LWIP_ASSERT("total_size <= NETDB_ELEM_SIZE: please report this!",
total_size <= NETDB_ELEM_SIZE);
ai = memp_malloc(MEMP_NETDB);
ai = (struct addrinfo *)memp_malloc(MEMP_NETDB);
if (ai == NULL) {
goto memerr;
}

View File

@ -240,7 +240,7 @@ dns_init()
{
ip_addr_t dnsserver;
dns_payload = LWIP_MEM_ALIGN(dns_payload_buffer);
dns_payload = (u8_t *)LWIP_MEM_ALIGN(dns_payload_buffer);
/* initialize default DNS server address */
DNS_SERVER_ADDRESS(&dnsserver);
@ -858,6 +858,7 @@ dns_enqueue(const char *name, dns_found_callback found, void *callback_arg)
u8_t i;
u8_t lseq, lseqi;
struct dns_table_entry *pEntry = NULL;
size_t namelen;
/* search an unused entry, or the oldest one */
lseq = lseqi = 0;
@ -897,7 +898,9 @@ dns_enqueue(const char *name, dns_found_callback found, void *callback_arg)
pEntry->seqno = dns_seqno++;
pEntry->found = found;
pEntry->arg = callback_arg;
strcpy(pEntry->name, name);
namelen = LWIP_MIN(strlen(name), DNS_MAX_NAME_LENGTH-1);
MEMCPY(pEntry->name, name, namelen);
pEntry->name[namelen] = 0;
/* force to send query without waiting timer */
dns_check_entry(i);