mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-18 20:10:53 +00:00
Fixed netconn_gethostbyname for LWIP_MPU_COMPATIBLE: removed invalid check on 'addr', copy 'name' since it could be located on the caller's stack
This commit is contained in:
parent
4d69d0eda5
commit
fc158ad5c0
@ -829,20 +829,19 @@ netconn_gethostbyname(const char *name, ip_addr_t *addr)
|
|||||||
|
|
||||||
API_VAR_ALLOC(struct dns_api_msg, MEMP_DNS_API_MSG, msg);
|
API_VAR_ALLOC(struct dns_api_msg, MEMP_DNS_API_MSG, msg);
|
||||||
#if LWIP_MPU_COMPATIBLE
|
#if LWIP_MPU_COMPATIBLE
|
||||||
if (addr == NULL) {
|
strncpy(API_VAR_REF(msg).name, name, DNS_MAX_NAME_LENGTH-1);
|
||||||
addr = IP_ADDR_ANY;
|
API_VAR_REF(msg).name[DNS_MAX_NAME_LENGTH-1] = 0;
|
||||||
}
|
#else /* LWIP_MPU_COMPATIBLE */
|
||||||
#else
|
|
||||||
msg.err = &err;
|
msg.err = &err;
|
||||||
msg.sem = &sem;
|
msg.sem = &sem;
|
||||||
API_VAR_REF(msg).addr = API_VAR_REF(addr);
|
API_VAR_REF(msg).addr = API_VAR_REF(addr);
|
||||||
|
API_VAR_REF(msg).name = name;
|
||||||
#endif /* LWIP_MPU_COMPATIBLE */
|
#endif /* LWIP_MPU_COMPATIBLE */
|
||||||
err = sys_sem_new(API_EXPR_REF(API_VAR_REF(msg).sem), 0);
|
err = sys_sem_new(API_EXPR_REF(API_VAR_REF(msg).sem), 0);
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
API_VAR_FREE(MEMP_DNS_API_MSG, msg);
|
API_VAR_FREE(MEMP_DNS_API_MSG, msg);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
API_VAR_REF(msg).name = name;
|
|
||||||
|
|
||||||
tcpip_callback(lwip_netconn_do_gethostbyname, &API_VAR_REF(msg));
|
tcpip_callback(lwip_netconn_do_gethostbyname, &API_VAR_REF(msg));
|
||||||
sys_sem_wait(API_EXPR_REF(API_VAR_REF(msg).sem));
|
sys_sem_wait(API_EXPR_REF(API_VAR_REF(msg).sem));
|
||||||
|
@ -140,7 +140,11 @@ struct api_msg {
|
|||||||
(see netconn_gethostbyname). */
|
(see netconn_gethostbyname). */
|
||||||
struct dns_api_msg {
|
struct dns_api_msg {
|
||||||
/** Hostname to query or dotted IP address string */
|
/** Hostname to query or dotted IP address string */
|
||||||
|
#if LWIP_MPU_COMPATIBLE
|
||||||
|
char name[DNS_MAX_NAME_LENGTH];
|
||||||
|
#else /* LWIP_MPU_COMPATIBLE */
|
||||||
const char *name;
|
const char *name;
|
||||||
|
#endif /* LWIP_MPU_COMPATIBLE */
|
||||||
/** Rhe resolved address is stored here */
|
/** Rhe resolved address is stored here */
|
||||||
ip_addr_t API_MSG_M_DEF(addr);
|
ip_addr_t API_MSG_M_DEF(addr);
|
||||||
/** This semaphore is posted when the name is resolved, the application thread
|
/** This semaphore is posted when the name is resolved, the application thread
|
||||||
|
Loading…
Reference in New Issue
Block a user