summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2019-02-20 17:51:22 -0500
committerRich Felker <dalias@aerifal.cx>2019-02-20 17:51:22 -0500
commit224d938c5e538ac37f84c6e9a01bd2095aa7081a (patch)
treec504ba01a156b537be6d61b2312386f33fcf8041 /src/network
parent9d44b6460ab603487dab4d916342d9ba4467e6b9 (diff)
downloadmusl-224d938c5e538ac37f84c6e9a01bd2095aa7081a.tar.gz
musl-224d938c5e538ac37f84c6e9a01bd2095aa7081a.tar.bz2
musl-224d938c5e538ac37f84c6e9a01bd2095aa7081a.tar.xz
musl-224d938c5e538ac37f84c6e9a01bd2095aa7081a.zip
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.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/getaddrinfo.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/network/getaddrinfo.c b/src/network/getaddrinfo.c
index 5ae8cbfb..209970ad 100644
--- a/src/network/getaddrinfo.c
+++ b/src/network/getaddrinfo.c
@@ -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++) {
- out[k].slot = i;
+ out[k].slot = k;
out[k].ai = (struct addrinfo){
.ai_family = addrs[i].family,
.ai_socktype = ports[j].socktype,