This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Fix off-by-one in nscd getservbyport call
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: libc-alpha at sourceware dot org
- Date: Mon, 11 Nov 2013 13:10:58 +0100
- Subject: Re: [PATCH] Fix off-by-one in nscd getservbyport call
- Authentication-results: sourceware.org; auth=none
- References: <mvmy54vrx15 dot fsf at hawking dot suse dot de>
On Mon, Nov 11, 2013 at 12:35:34PM +0100, Andreas Schwab wrote:
> When nscd is in use, getservbyport ignores the protocol name when
> looking up the key. There are a few services where it matters, and it
> also didn't return an error when the port/protocol combination isn't
> defined.
>
Look ok, a problem was that
nscd_getserv_r (const char *crit, size_t critlen, const char *proto,...
copied string by
memcpy (__mempcpy (__mempcpy (key, crit, critlen),
"/", 1), proto ?: "", protolen + 1);
> Andreas.
>
> [BZ #16153]
> * nscd/nscd_getserv_r.c (__nscd_getservbyport_r): Don't include
> terminating NUL in key length.
>
> diff --git a/nscd/nscd_getserv_r.c b/nscd/nscd_getserv_r.c
> index c9c890c..7728258 100644
> --- a/nscd/nscd_getserv_r.c
> +++ b/nscd/nscd_getserv_r.c
> @@ -54,7 +54,7 @@ __nscd_getservbyport_r (int port, const char *proto,
> portstr[sizeof (portstr) - 1] = '\0';
> char *cp = _itoa_word (port, portstr + sizeof (portstr) - 1, 10, 0);
>
> - return nscd_getserv_r (cp, portstr + sizeof (portstr) - cp, proto,
> + return nscd_getserv_r (cp, portstr + sizeof (portstr) - 1 - cp, proto,
> GETSERVBYPORT, result_buf, buf, buflen, result);
> }
>
> --
> 1.8.4.3
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
--
Daemon escaped from pentagram