# HG changeset patch # User Vitaliy Gusev # Date 1321518013 -10800 # Node ID e7b96961e15f9827630a0026ef7277dd2757558e # Parent eb88ab5c1435dd625ada824c779333b07356c452 393 Invalid nd_hostservlist contents crash mountd Reviewed by: Garrett D'Amore Reviewed by: Gordon Ross Approved by: Richard Lowe diff -r eb88ab5c1435 -r e7b96961e15f usr/src/head/nss_dbdefs.h --- a/usr/src/head/nss_dbdefs.h Fri Jan 27 00:27:36 2012 -0500 +++ b/usr/src/head/nss_dbdefs.h Thu Nov 17 11:20:13 2011 +0300 @@ -666,6 +666,7 @@ (str)->key2str = NULL, \ (str)->returnval = 0, \ (str)->returnlen = 0, \ + (str)->h_errno = 0, \ (str)->erange = 0) #define NSS_XbyY_INIT_EXT(str, res, bufp, len, func, kfunc) (\ @@ -677,6 +678,7 @@ (str)->key2str = (kfunc), \ (str)->returnval = 0, \ (str)->returnlen = 0, \ + (str)->h_errno = 0, \ (str)->erange = 0) #define NSS_XbyY_FINI(str) (\ diff -r eb88ab5c1435 -r e7b96961e15f usr/src/lib/libnsl/nss/netdir_inet.c --- a/usr/src/lib/libnsl/nss/netdir_inet.c Fri Jan 27 00:27:36 2012 -0500 +++ b/usr/src/lib/libnsl/nss/netdir_inet.c Thu Nov 17 11:20:13 2011 +0300 @@ -20,6 +20,7 @@ */ /* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -585,9 +586,7 @@ ndbuf4switch->buflen, &h_errnop); if (he == NULL) { NSS_XbyY_FREE(&ndbuf4switch); - _nderror = h_errnop ? - __herrno2netdir(h_errnop) : - ND_NOHOST; + _nderror = __herrno2netdir(h_errnop); return (_nderror); } /* @@ -673,9 +672,7 @@ args->arg.nss.host6.flags, &h_errnop); if (he == NULL) { NSS_XbyY_FREE(&ndbuf4switch); - _nderror = h_errnop ? - __herrno2netdir(h_errnop) : - ND_NOHOST; + _nderror = __herrno2netdir(h_errnop); return (_nderror); } /* @@ -1310,7 +1307,8 @@ res = nss_search(&db_root_hosts, _nss_initf_hosts, NSS_DBOP_HOSTS_BYNAME, &arg); arg.status = res; - *h_errnop = arg.h_errno; + if (res != NSS_SUCCESS) + *h_errnop = arg.h_errno ? arg.h_errno : __nss2herrno(res); if (arg.returnval != NULL) order_haddrlist_af(result->h_addrtype, result->h_addr_list); return ((struct hostent *)NSS_XbyY_FINI(&arg)); @@ -1331,7 +1329,8 @@ res = nss_search(&db_root_ipnodes, _nss_initf_ipnodes, NSS_DBOP_IPNODES_BYNAME, &arg); arg.status = res; - *h_errnop = arg.h_errno; + if (res != NSS_SUCCESS) + *h_errnop = arg.h_errno ? arg.h_errno : __nss2herrno(res); if (arg.returnval != NULL) order_haddrlist_af(result->h_addrtype, result->h_addr_list); return ((struct hostent *)NSS_XbyY_FINI(&arg)); @@ -1352,7 +1351,8 @@ res = nss_search(&db_root_hosts, _nss_initf_hosts, NSS_DBOP_HOSTS_BYADDR, &arg); arg.status = res; - *h_errnop = arg.h_errno; + if (res != NSS_SUCCESS) + *h_errnop = arg.h_errno ? arg.h_errno : __nss2herrno(res); return (struct hostent *)NSS_XbyY_FINI(&arg); } @@ -1371,7 +1371,8 @@ res = nss_search(&db_root_ipnodes, _nss_initf_ipnodes, NSS_DBOP_IPNODES_BYADDR, &arg); arg.status = res; - *h_errnop = arg.h_errno; + if (res != NSS_SUCCESS) + *h_errnop = arg.h_errno ? arg.h_errno : __nss2herrno(res); return (struct hostent *)NSS_XbyY_FINI(&arg); }