[PATCH] avoid buffer overflow in sunrpc clnt_create (BZ #22542)
Dmitry V. Levin
ldv@altlinux.org
Tue Feb 6 21:41:00 GMT 2018
On Mon, Dec 04, 2017 at 12:04:12AM -0800, Paul Eggert wrote:
> Dmitry V. Levin wrote:
> > Do people really expect that? Assuming that people are aware
> > of linux kernel behaviour, why would they expect that?
>
> These days, it's because strncpy format is obsolete and is not something
> programmers are ordinarily aware of. When in doubt (which there seems to be
> here), glibc should use null-terminated strings rather than strncpy format.
Is there any statistics what programmers are ordinarily aware of?
I have no doubts that some valid code[1] no longer compiles with
-Werror=stringop-truncation, and the only plausible fix is to mark
struct sockaddr_un.sun_path with __attribute_nonstring__.
I think we should revisit the patch submitted by Martin.
[1] strace HEAD's tests no longer build in Fedora Rawhide with the following
diagnostics:
net-accept-connect.c: In function ‘main’:
net-accept-connect.c:57:2: error: ‘strncpy’ specified bound 108 equals destination size [-Werror=stringop-truncation]
strncpy(addr.sun_path, av[1], sizeof(addr.sun_path));
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20180206/5dcb13cb/attachment.sig>
More information about the Libc-alpha
mailing list