Fix mg_resolve2()

PUBLISHED_FROM=b0df728a75073c6ea9fc1984bb6a6b463f539347
This commit is contained in:
Sergey Lyubka 2019-05-24 13:14:37 +01:00 committed by Cesanta Bot
parent 1fb9f922b0
commit 3fc61a3edc
2 changed files with 4 additions and 4 deletions

View File

@ -2708,8 +2708,8 @@ static int mg_resolve2(const char *host, struct in_addr *ina) {
return 0; return 0;
} }
for (p = servinfo; p != NULL; p = p->ai_next) { for (p = servinfo; p != NULL; p = p->ai_next) {
memcpy(&h, &p->ai_addr, sizeof(struct sockaddr_in *)); memcpy(&h, &p->ai_addr, sizeof(h));
memcpy(ina, &h->sin_addr, sizeof(ina)); memcpy(ina, &h->sin_addr, sizeof(*ina));
} }
freeaddrinfo(servinfo); freeaddrinfo(servinfo);
return 1; return 1;

View File

@ -341,8 +341,8 @@ static int mg_resolve2(const char *host, struct in_addr *ina) {
return 0; return 0;
} }
for (p = servinfo; p != NULL; p = p->ai_next) { for (p = servinfo; p != NULL; p = p->ai_next) {
memcpy(&h, &p->ai_addr, sizeof(struct sockaddr_in *)); memcpy(&h, &p->ai_addr, sizeof(h));
memcpy(ina, &h->sin_addr, sizeof(ina)); memcpy(ina, &h->sin_addr, sizeof(*ina));
} }
freeaddrinfo(servinfo); freeaddrinfo(servinfo);
return 1; return 1;