This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix off-by-one in nscd getservbyport call


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]