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] add attribute nonstring


On 11/14/2017 07:27 PM, Joseph Myers wrote:
On Tue, 14 Nov 2017, Florian Weimer wrote:

However, the original patch should really use strnlen or memchr, and not
strlen.  As posted, the strlen is either invalid because the array is not
NUL-terminated, or it passes because the string is short enough.

if_nametoindex takes a char * argument.  POSIX doesn't say explicitly, but
I'd presume that must be a NUL-terminated string, with undefined behavior
otherwise.  That's separate from what the kernel interface is.

Oh, you are of course right.  strlen is fine under these circumstances.

So the only thing that's missing is the __set_errno (ENODEV); call, I think. (It's what the ioctl should fail with for an unknown interface name.)

Thanks,
Florian


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