public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Martin Sebor <msebor@gmail.com>
Cc: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH] add attribute nonstring
Date: Sun, 12 Nov 2017 20:39:00 -0000	[thread overview]
Message-ID: <7cacef34-0bd2-94c7-6bea-fcaeb0668d97@cs.ucla.edu> (raw)
In-Reply-To: <86960833-8738-3b92-7ddf-a5cc25844bfe@gmail.com>

[Dropping tz@iana.org as this email isn't relevant to tzdb.]

Martin Sebor wrote:
> I tried to make only minimal changes to suppress
> the new warning to avoid excessive churn.

As the main goal here is to find bugs not to pacify GCC, it's helpful to take 
these diagnostics as an opportunity to look more carefully at the strncpy calls. 
I just now looked at the other two data structures affected by the patch, and 
found some issues.

First, the patch to sysdeps/gnu/bits/utmp.h seems reasonable, as the members 
ut_user etc. have used strncpy format since the 1970s and people who deal with 
this format are used to it. However, this format does not appear to be 
documented in the manual. I suggest accompanying it with a patch to the part of 
manual/users.texi that talks about ut_user etc., so that the __NONSTRING issue 
is documented there.

Second, the patch to sysdeps/gnu/net/if.h is dubious. Its goal appears to be to 
pacify calls like the first call to strncpy in 
sysdeps/unix/sysv/linux/if_index.c. But that first call appears to be a bug in 
glibc, since the underlying Linux system call expects a null-terminated string. 
My guess is that
this particular data structure should indeed be a null-terminated string, and 
should not be marked with __NONSTRING, and that we should instead change the 
glibc code to not use strncpy here. I suppose the code should report an error 
instead of creating a non-null-terminated array, and that it need not initialize 
the rest of the array to zeros.

  reply	other threads:[~2017-11-12 20:39 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-10 17:31 Martin Sebor
2017-11-10 17:54 ` Joseph Myers
2017-11-10 23:11   ` Martin Sebor
2017-11-10 23:46     ` Joseph Myers
2017-11-14 17:58       ` Joseph Myers
2017-11-15 22:09     ` Steve Ellcey
2017-11-15 23:05       ` Martin Sebor
2017-11-15 23:14         ` Joseph Myers
2017-11-21  5:27           ` Paul Eggert
2017-11-21 13:38             ` Joseph Myers
2017-11-12  9:06 ` Paul Eggert
2017-11-12 17:33   ` Martin Sebor
2017-11-12 20:39     ` Paul Eggert [this message]
2017-11-12 23:49       ` Martin Sebor
2017-11-13 17:35         ` Steve Ellcey
2017-11-14 16:37           ` Joseph Myers
2017-11-14 16:50           ` Florian Weimer
2017-11-14 17:06             ` Joseph Myers
2017-11-14 17:55               ` Andreas Schwab
2017-11-14 18:21                 ` Florian Weimer
2017-11-14 18:27                   ` Joseph Myers
2017-11-14 18:29                     ` Florian Weimer
2017-11-14 23:22                       ` Steve Ellcey
2017-11-15 10:48                         ` Florian Weimer
2017-11-15 17:58                           ` glibc failures on aarch64: (Was Re: [PATCH] add attribute nonstring) Steve Ellcey
2017-11-16  0:37                             ` Adhemerval Zanella
2017-11-17 12:49                             ` Szabolcs Nagy
2017-11-17 12:57                               ` Florian Weimer
2017-11-13  0:50   ` [PATCH] add attribute nonstring Joseph Myers
2017-11-27 11:05 ` Siddhesh Poyarekar
2017-11-27 16:04   ` Martin Sebor
2017-11-27 16:24     ` Siddhesh Poyarekar
2017-11-27 16:26       ` Siddhesh Poyarekar

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=7cacef34-0bd2-94c7-6bea-fcaeb0668d97@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=libc-alpha@sourceware.org \
    --cc=msebor@gmail.com \
    /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).