From: Ken Raeburn Date: Wed, 21 Jun 2006 00:28:21 +0000 (+0000) Subject: (GET_HOST_BY_NAME, GET_HOST_BY_ADDR) [GETHOSTBYNAME_RETURNS_INT]: Test X-Git-Tag: krb5-1.6-alpha1~281 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=53f86fb288eec10113aaab3412544b5f0c03db8b;p=krb5.git (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. ticket: 2759 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18183 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/util/support/fake-addrinfo.c b/src/util/support/fake-addrinfo.c index a622302b8..cdc2fdd04 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), &TMP.hp, \ + &my_h_err); \ + (HP) = (((my_ret != 0) || (TMP.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) || (TMP.hp != &TMP.ent)) \ ? 0 \ : &TMP.ent); \ (ERR) = my_h_err; \