diff options
Diffstat (limited to 'main/musl/1003-fix-gethostby-_r-result-pointer-value-on-error.patch')
-rw-r--r-- | main/musl/1003-fix-gethostby-_r-result-pointer-value-on-error.patch | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/main/musl/1003-fix-gethostby-_r-result-pointer-value-on-error.patch b/main/musl/1003-fix-gethostby-_r-result-pointer-value-on-error.patch new file mode 100644 index 000000000..e753d7ede --- /dev/null +++ b/main/musl/1003-fix-gethostby-_r-result-pointer-value-on-error.patch @@ -0,0 +1,43 @@ +From a9c5a6208a5afdfbc3f9855887ad39b0d1921514 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi> +Date: Fri, 20 Jun 2014 13:53:23 +0300 +Subject: [PATCH] fix gethostby*_r result pointer value on error + +man-pages states that the GNU extension functions gethostbyaddr_r, +gethostbyname_r and gethostbyname2_r are guaranteed to set result +pointer to NULL in case of error or no result. E.g. openjdk7 can +crash unless this is not done (it checks for result pointer value +only and ignores the returned error code). +--- + src/network/gethostbyaddr_r.c | 2 ++ + src/network/gethostbyname2_r.c | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/src/network/gethostbyaddr_r.c b/src/network/gethostbyaddr_r.c +index 73e7644..66e0330 100644 +--- a/src/network/gethostbyaddr_r.c ++++ b/src/network/gethostbyaddr_r.c +@@ -18,6 +18,8 @@ int gethostbyaddr_r(const void *a, socklen_t l, int af, + socklen_t sl = af==AF_INET6 ? sizeof sa.sin6 : sizeof sa.sin; + int i; + ++ *res = 0; ++ + /* Load address argument into sockaddr structure */ + if (af==AF_INET6 && l==16) memcpy(&sa.sin6.sin6_addr, a, 16); + else if (af==AF_INET && l==4) memcpy(&sa.sin.sin_addr, a, 4); +diff --git a/src/network/gethostbyname2_r.c b/src/network/gethostbyname2_r.c +index aa8b0a9..81f71d2 100644 +--- a/src/network/gethostbyname2_r.c ++++ b/src/network/gethostbyname2_r.c +@@ -17,6 +17,7 @@ int gethostbyname2_r(const char *name, int af, + int i, cnt; + size_t align, need; + ++ *res = 0; + cnt = __lookup_name(addrs, canon, name, af, AI_CANONNAME); + if (cnt<0) switch (cnt) { + case EAI_NONAME: +-- +2.0.0 + |