[dm-devel] [PATCH 07/30] libmpathcmd: use target length in strncpy() call

Martin Wilck mwilck at suse.de
Mon Jun 24 08:23:57 UTC 2019


On Fri, 2019-06-21 at 14:23 -0500, Benjamin Marzinski wrote:
> On Fri, Jun 07, 2019 at 03:05:29PM +0200, Martin Wilck wrote:
> 
> Not a big deal since default socket is a defined string, but since we
> are writing to &addr.sun_path[1], if DEFAULT_SOCKET were of size >=
> "sizeof(addr.sun_path) - 1", the strncpy() would fill all of
> addr.sun_path, without leaving any space for the the null byte at the
> end. I assume you meant to change this to be strlcpy() instead of
> leaving it as strncpy().

I double-checked the man pages unix(7), and I found that abstract unix
socket names do not have to be zero-terminated ("null bytes in the name
have no special significance"). So strncpy() is actually correct in
this case. But the length argument to bind() should be checked.

Thanks,
Martin





More information about the dm-devel mailing list