[PATCH] nss_wrappe fix comparison between pointer and '\0'
Douglas Bagnall
douglas.bagnall at catalyst.net.nz
Tue Aug 15 23:12:54 UTC 2017
hi Gary,
On 16/08/17 07:04, Gary Lockyer via samba-technical wrote:
> fixes GCC 7.1 warning, pointers being compared to '\0' without a
> dereference.
>
> Review appreciated.
I actually found this a while ago and Andreas reminded me to patch
against the upstream nss_wrapper repository:
https://lists.samba.org/archive/samba-technical/2017-July/121750.html
I gave that task a non-urgent priority. It turns out I was waiting for
you to prompt me. My attached version is slightly different,
explicitly ignoring an empty string.
Douglas
>
> Gary
>
>
> 0001-nss_wrapper-fix-comparison-of-pointers-to-0.patch
>
>
> From f4f10c84045e94ad440797b3141f78fccfa6c5a4 Mon Sep 17 00:00:00 2001
> From: Gary Lockyer <gary at catalyst.net.nz>
> Date: Tue, 15 Aug 2017 12:21:49 +1200
> Subject: [PATCH] nss_wrapper: fix comparison of pointers to '\0'
>
> Patch to fix comparison of pointers to '\0', without a dereference
> GCC 7.1 gave the following warning:
> error: comparison between pointer and zero character constant
> [-Werror=pointer-compare]
>
> Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
> ---
> lib/nss_wrapper/nss_wrapper.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/nss_wrapper/nss_wrapper.c b/lib/nss_wrapper/nss_wrapper.c
> index 82581b1..27f13d6 100644
> --- a/lib/nss_wrapper/nss_wrapper.c
> +++ b/lib/nss_wrapper/nss_wrapper.c
> @@ -1568,7 +1568,7 @@ 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')) ||
> + if (((*env != '\0') && (*endptr == '\0')) ||
> (max_hostents_tmp == 0)) {
> NWRAP_LOG(NWRAP_LOG_DEBUG,
> "Error parsing NSS_WRAPPER_MAX_HOSTENTS "
> -- 2.7.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fix-logic-for-finding-NSS_WRAPPER_MAX_HOSTENTS-error.patch
Type: text/x-patch
Size: 2068 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20170816/a82f1973/0001-fix-logic-for-finding-NSS_WRAPPER_MAX_HOSTENTS-error.bin>
More information about the samba-technical
mailing list