From: Martin Sebor <msebor@gmail.com>
To: Carlos O'Donell <carlos@redhat.com>,
GNU C Library <libc-alpha@sourceware.org>
Subject: Re: nonstrings in Glibc
Date: Tue, 21 Nov 2017 23:41:00 -0000 [thread overview]
Message-ID: <2d1095ea-a158-f3ff-2cc4-006dea8387e6@gmail.com> (raw)
In-Reply-To: <797b60f7-1bd0-2b05-c25b-385ea3b04e68@redhat.com>
On 11/20/2017 11:20 AM, Carlos O'Donell wrote:
> On 11/20/2017 08:54 AM, Martin Sebor wrote:
>> I'm done testing my update to the -Wstringop-truncation GCC patch
>> to find misuses of non-string arrays. With the very limited use
>> of attribute nonstring it only found one potential bug (22447).
>> I've been looking at other uses of strncpy in Glibc to see if there
>> are other arrays that would benefit from the attribute. I'm not
>> sufficiently familiar with Glibc data structures so it's a very
>> slow going. Could someone help suggests data structures with
>> array members that might be candidates?
>
> struct sockaddr's sun_path?
>
> http://thread.gmane.org/gmane.comp.standards.posix.austin.general/5735
>
> Is that what you need help finding?
Yes, that's what I'm looking for, thanks!
From the referenced thread it sounds like POSIX doesn't require
sun_path to be nul-terminated and BSD UNIX doesn't terminate it.
But I'm not sure what happens on Linux. According to Michael
Kerrisk's response it sounds like it is nul-terminated, but
then according to the longer discussion on linux.kernel.api
it sounds like it isn't. Which is it?
If it's not guaranteed to be nul-terminated then the following
suggests the code in clntunix_create might be unsafe:
clnt_unix.c: In function âclntunix_createâ:
clnt_unix.c:137:13: warning: âstrlenâ argument 1 declared attribute
ânonstringâ [-Wstringop-overflow=]
len = strlen (raddr->sun_path) + sizeof (raddr->sun_family) + 1;
^~~~~~~~~~~~~~~~~~~~~~~~
Martin
next prev parent reply other threads:[~2017-11-21 23:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-20 16:54 Martin Sebor
2017-11-20 17:59 ` Paul Eggert
2017-11-20 18:44 ` Martin Sebor
2017-11-21 0:45 ` Paul Eggert
2017-11-20 18:20 ` Carlos O'Donell
2017-11-20 18:41 ` Florian Weimer
2017-11-21 21:21 ` Martin Sebor
2017-11-21 21:34 ` Florian Weimer
2017-11-21 21:37 ` Zack Weinberg
2017-11-21 22:31 ` Andreas Schwab
2017-11-21 22:39 ` Florian Weimer
2017-11-21 22:47 ` Joseph Myers
2017-11-21 23:41 ` Martin Sebor [this message]
2017-11-22 0:14 ` Dmitry V. Levin
2017-11-27 16:25 ` Martin Sebor
2017-11-27 16:25 ` Martin Sebor
2017-11-27 16:40 ` Carlos O'Donell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2d1095ea-a158-f3ff-2cc4-006dea8387e6@gmail.com \
--to=msebor@gmail.com \
--cc=carlos@redhat.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).