mirror of git://git.musl-libc.org/musl
fix invalid free of partial addrinfo list with multiple services
the backindex stored by getaddrinfo to allow freeaddrinfo to perform partial-free wrongly used the address result index, rather than the output slot index, and thus was only valid when they were equal (nservs==1). patch based on report with proposed fix by Markus Wichmann.
This commit is contained in:
parent
9d44b6460a
commit
224d938c5e
|
@ -104,7 +104,7 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru
|
||||||
}
|
}
|
||||||
|
|
||||||
for (k=i=0; i<naddrs; i++) for (j=0; j<nservs; j++, k++) {
|
for (k=i=0; i<naddrs; i++) for (j=0; j<nservs; j++, k++) {
|
||||||
out[k].slot = i;
|
out[k].slot = k;
|
||||||
out[k].ai = (struct addrinfo){
|
out[k].ai = (struct addrinfo){
|
||||||
.ai_family = addrs[i].family,
|
.ai_family = addrs[i].family,
|
||||||
.ai_socktype = ports[j].socktype,
|
.ai_socktype = ports[j].socktype,
|
||||||
|
|
Loading…
Reference in New Issue