[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [torsocks/master] gethostbyaddr_r: always assign result



commit 446ce04bb31a023712f5ff74a6a0649606286662
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date:   Mon Nov 19 10:18:04 2018 -0500

    gethostbyaddr_r: always assign result
    
    Originating from: https://bugzilla.redhat.com/show_bug.cgi?id=1601259
    
    Patch by "cHBWyJuH".
    
    Fixes #26794
    
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
 src/lib/gethostbyname.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/lib/gethostbyname.c b/src/lib/gethostbyname.c
index df84e14..b1b2183 100644
--- a/src/lib/gethostbyname.c
+++ b/src/lib/gethostbyname.c
@@ -349,6 +349,9 @@ LIBC_GETHOSTBYNAME_R_RET_TYPE tsocks_gethostbyname_r(LIBC_GETHOSTBYNAME_R_SIG)
 		char padding[];
 	} *data;
 
+	/* result must be NULL if no entry is found or if an error occurs */
+	*result = NULL;
+
 	DBG("[gethostbyname_r] Requesting %s hostname", name);
 
 	if (!name) {
@@ -390,6 +393,9 @@ LIBC_GETHOSTBYNAME_R_RET_TYPE tsocks_gethostbyname_r(LIBC_GETHOSTBYNAME_R_SIG)
 	he->h_length = sizeof(in_addr_t);
 	he->h_addrtype = AF_INET;
 
+	/* Assign result as specified by the documentation */
+	*result = he;
+
 	DBG("[gethostbyname_r] Hostname %s resolved to %u.%u.%u.%u", name,
 			ip & 0XFF, (ip >> 8) & 0XFF, (ip >> 16) & 0XFF, (ip >> 24) & 0xFF);
 

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits