From: Douglas Bagnall Date: Thu, 19 Oct 2017 08:56:15 +0000 (+0200) Subject: nwrap: Fix strotoul checks for NSS_WRAPPER_MAX_HOSTENTS X-Git-Tag: tevent-0.9.34~167 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=42e7671226fe410ef06edb3a35906bc451e2fa44;p=thirdparty%2Fsamba.git nwrap: Fix strotoul checks for NSS_WRAPPER_MAX_HOSTENTS The env and endptr pointers need to be dereferenced, but that is not enough: we don't really want to regard an empty string (*env == '\0') as a valid number. Found by GCC 8.0.0 20170705 (experimental). [2095/4103] Compiling lib/nss_wrapper/nss_wrapper.c ../lib/nss_wrapper/nss_wrapper.c: In function "nwrap_init": ../lib/nss_wrapper/nss_wrapper.c:1571:13: warning: comparison between pointer and zero character constant [-Wpointer-compare] if (((env != '\0') && (endptr == '\0')) || ^~ ../lib/nss_wrapper/nss_wrapper.c:1571:9: note: did you mean to dereference the pointer? if (((env != '\0') && (endptr == '\0')) || ^ ../lib/nss_wrapper/nss_wrapper.c:1571:33: warning: comparison between pointer and zero character constant [-Wpointer-compare] if (((env != '\0') && (endptr == '\0')) || ^~ ../lib/nss_wrapper/nss_wrapper.c:1571:26: note: did you mean to dereference the pointer? if (((env != '\0') && (endptr == '\0')) || Signed-off-by: Douglas Bagnall Reviewed-by: Andreas Schneider Reviewed-by: Ralph Boehme Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Thu Oct 19 16:42:17 CEST 2017 on sn-devel-144 --- diff --git a/lib/nss_wrapper/nss_wrapper.c b/lib/nss_wrapper/nss_wrapper.c index 82581b17aaf..566d02ca34b 100644 --- a/lib/nss_wrapper/nss_wrapper.c +++ b/lib/nss_wrapper/nss_wrapper.c @@ -1567,8 +1567,9 @@ static void nwrap_init(void) env = getenv("NSS_WRAPPER_MAX_HOSTENTS"); if (env != NULL) { - max_hostents_tmp = (size_t)strtol(env, &endptr, 10); - if (((env != '\0') && (endptr == '\0')) || + max_hostents_tmp = (size_t)strtoul(env, &endptr, 10); + if ((*env == '\0') || + (*endptr != '\0') || (max_hostents_tmp == 0)) { NWRAP_LOG(NWRAP_LOG_DEBUG, "Error parsing NSS_WRAPPER_MAX_HOSTENTS "