mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-18 20:10:53 +00:00
patch by Mason: fixed bug #35907: lwip_gethostbyname_r returns an invalid h_addr_list
This commit is contained in:
parent
52d41d19d3
commit
c6e4b8f829
@ -76,6 +76,9 @@ HISTORY
|
|||||||
|
|
||||||
++ Bugfixes:
|
++ Bugfixes:
|
||||||
|
|
||||||
|
2012-03-20: Simon Goldschmidt (patch by Mason)
|
||||||
|
* netdb.c: fixed bug #35907: lwip_gethostbyname_r returns an invalid h_addr_list
|
||||||
|
|
||||||
2012-03-12: Simon Goldschmidt (patch by Bostjan Meglic)
|
2012-03-12: Simon Goldschmidt (patch by Bostjan Meglic)
|
||||||
* ppp.c: fixed bug #35809: PPP GetMask(): Compiler warning on big endian,
|
* ppp.c: fixed bug #35809: PPP GetMask(): Compiler warning on big endian,
|
||||||
possible bug on little endian system
|
possible bug on little endian system
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
/** helper struct for gethostbyname_r to access the char* buffer */
|
/** helper struct for gethostbyname_r to access the char* buffer */
|
||||||
struct gethostbyname_r_helper {
|
struct gethostbyname_r_helper {
|
||||||
ip_addr_t *addrs;
|
ip_addr_t *addr_list[2];
|
||||||
ip_addr_t addr;
|
ip_addr_t addr;
|
||||||
char *aliases;
|
char *aliases;
|
||||||
};
|
};
|
||||||
@ -180,7 +180,7 @@ lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf,
|
|||||||
}
|
}
|
||||||
/* first thing to do: set *result to nothing */
|
/* first thing to do: set *result to nothing */
|
||||||
*result = NULL;
|
*result = NULL;
|
||||||
if ((name == NULL) || (ret == NULL) || (buf == 0)) {
|
if ((name == NULL) || (ret == NULL) || (buf == NULL)) {
|
||||||
/* not all arguments given */
|
/* not all arguments given */
|
||||||
*h_errnop = EINVAL;
|
*h_errnop = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
@ -197,7 +197,7 @@ lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf,
|
|||||||
hostname = ((char*)h) + sizeof(struct gethostbyname_r_helper);
|
hostname = ((char*)h) + sizeof(struct gethostbyname_r_helper);
|
||||||
|
|
||||||
/* query host IP address */
|
/* query host IP address */
|
||||||
err = netconn_gethostbyname(name, &(h->addr));
|
err = netconn_gethostbyname(name, &h->addr);
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
LWIP_DEBUGF(DNS_DEBUG, ("lwip_gethostbyname(%s) failed, err=%d\n", name, err));
|
LWIP_DEBUGF(DNS_DEBUG, ("lwip_gethostbyname(%s) failed, err=%d\n", name, err));
|
||||||
*h_errnop = HOST_NOT_FOUND;
|
*h_errnop = HOST_NOT_FOUND;
|
||||||
@ -209,13 +209,14 @@ lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf,
|
|||||||
hostname[namelen] = 0;
|
hostname[namelen] = 0;
|
||||||
|
|
||||||
/* fill hostent */
|
/* fill hostent */
|
||||||
h->addrs = &(h->addr);
|
h->addr_list[0] = &h->addr;
|
||||||
|
h->addr_list[1] = NULL;
|
||||||
h->aliases = NULL;
|
h->aliases = NULL;
|
||||||
ret->h_name = (char*)hostname;
|
ret->h_name = hostname;
|
||||||
ret->h_aliases = &(h->aliases);
|
ret->h_aliases = &h->aliases;
|
||||||
ret->h_addrtype = AF_INET;
|
ret->h_addrtype = AF_INET;
|
||||||
ret->h_length = sizeof(ip_addr_t);
|
ret->h_length = sizeof(ip_addr_t);
|
||||||
ret->h_addr_list = (char**)&(h->addrs);
|
ret->h_addr_list = (char**)&h->addr_list;
|
||||||
|
|
||||||
/* set result != NULL */
|
/* set result != NULL */
|
||||||
*result = ret;
|
*result = ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user