From 6a43f79bf0c235fc49d2e20d43d0c66b0bb8a37d Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Mon, 26 Jun 2006 03:21:41 +0000 Subject: [PATCH] pull up r18183:18184 from trunk r18183@cathode-dark-space: raeburn | 2006-06-20 20:28:21 -0400 ticket: 2759 tags: pullup (GET_HOST_BY_NAME, GET_HOST_BY_ADDR) [GETHOSTBYNAME_RETURNS_INT]: Test the output hostent pointer as an additional way of checking for errors. Original patch from Nalin Dahyabhai, needed some tweaking to fit in current sources, especially as updated in ticket 3911. r18184@cathode-dark-space: raeburn | 2006-06-20 20:31:19 -0400 ticket: 2759 *sigh* Stupid typo in last change. ticket: 2759 version_fixed: 1.5 git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-5@18226 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/support/fake-addrinfo.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/util/support/fake-addrinfo.c b/src/util/support/fake-addrinfo.c index a622302b8..eba4c74b6 100644 --- a/src/util/support/fake-addrinfo.c +++ b/src/util/support/fake-addrinfo.c @@ -200,11 +200,12 @@ typedef struct { } GET_HOST_TMP; #define GET_HOST_BY_NAME(NAME, HP, ERR, TMP) \ { \ - struct hostent *my_hp; \ - int my_h_err; \ - (HP) = (gethostbyname_r((NAME), &TMP.ent, \ - TMP.buf, sizeof (TMP.buf), &TMP.hp, \ - &my_h_err) \ + struct hostent *my_hp = NULL; \ + int my_h_err, my_ret; \ + my_ret = gethostbyname_r((NAME), &TMP.ent, \ + TMP.buf, sizeof (TMP.buf), &my_hp, \ + &my_h_err); \ + (HP) = (((my_ret != 0) || (my_hp != &TMP.ent)) \ ? 0 \ : &TMP.ent); \ (ERR) = my_h_err; \ @@ -212,10 +213,11 @@ typedef struct { #define GET_HOST_BY_ADDR(ADDR, ADDRLEN, FAMILY, HP, ERR, TMP) \ { \ struct hostent *my_hp; \ - int my_h_err; \ - (HP) = (gethostbyaddr_r((ADDR), (ADDRLEN), (FAMILY), &TMP.ent, \ - TMP.buf, sizeof (TMP.buf), &my_hp, \ - &my_h_err) \ + int my_h_err, my_ret; \ + my_ret = gethostbyaddr_r((ADDR), (ADDRLEN), (FAMILY), &TMP.ent, \ + TMP.buf, sizeof (TMP.buf), &my_hp, \ + &my_h_err); \ + (HP) = (((my_ret != 0) || (my_hp != &TMP.ent)) \ ? 0 \ : &TMP.ent); \ (ERR) = my_h_err; \ -- 2.26.2