From: "Maciej W. Rozycki" <macro@mips.com>
To: DJ Delorie <dj@redhat.com>
Cc: <libc-alpha@sourceware.org>
Subject: [committed v3] nisplus: Correct pwent parsing issue and resulting build error [BZ #23266]
Date: Wed, 27 Jun 2018 20:14:00 -0000 [thread overview]
Message-ID: <alpine.DEB.2.00.1806271622200.20622@tp.orcam.me.uk> (raw)
In-Reply-To: <xnzhziib7l.fsf@greed.delorie.com>
Copy and null-terminate NIS+ password file UID and GID entries whose
length is non-zero and are not terminated, in addition to empty ones,
fixing a bug and a compilation issue causing an error with GCC 8:
nss_nisplus/nisplus-parser.c: In function '_nss_nisplus_parse_pwent':
nss_nisplus/nisplus-parser.c:90:7: error: 'strncpy' destination unchanged after copying no bytes [-Werror=stringop-truncation]
strncpy (first_unused, numstr, len);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nss_nisplus/nisplus-parser.c:106:7: error: 'strncpy' destination unchanged after copying no bytes [-Werror=stringop-truncation]
strncpy (first_unused, numstr, len);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
introduced with commit ac05397075f6:
commit ac05397075f621cfdbe1db527c96167a58b6d18e
Author: Ulrich Drepper <drepper@redhat.com>
Date: Sun Apr 30 07:01:26 2006 +0000
* nis/nss_nisplus/nisplus-parser.c: Minor optimizations and
cleanups. Avoid copying data if it can be used in the old place.
(no mailing list reference available). Obviously regardless of the
recently added compiler diagnostics causing a build error this code has
been long non-functional, so I guess NIS+ servers have been supplying
strings that are non-empty and have already been null-terminated.
Which in turn made it unnecessary to make a null-terminated copy,
masking this bug.
[BZ #23266]
* nis/nss_nisplus/nisplus-parser.c (_nss_nisplus_parse_pwent):
Copy and null-terminate entries that are not terminated, in
addition to empty ones.
---
On Mon, 25 Jun 2018, DJ Delorie wrote:
> > Ping for:
> >
> > <https://patchwork.sourceware.org/patch/27908/>
> >
> > Previous discussion:
> >
> > <https://patchwork.sourceware.org/patch/27906/>
>
> LGTM
Thanks, applied now, with two minor updates:
* s/compilation/build/ in the heading so that it fits in 79 columns with
GIT's indentation applied,
* a comma added after "are not terminated" in the description and
ChangeLog, for clarity,
which I have decided that qualify as trivial and therefore not requiring
further consensus.
Here's the actual version committed, for future reference.
Maciej
---
ChangeLog | 7 +++++++
nis/nss_nisplus/nisplus-parser.c | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/nis/nss_nisplus/nisplus-parser.c b/nis/nss_nisplus/nisplus-parser.c
index 8dc021e..d2b0633 100644
--- a/nis/nss_nisplus/nisplus-parser.c
+++ b/nis/nss_nisplus/nisplus-parser.c
@@ -82,7 +82,7 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw,
char *numstr = NISOBJVAL (2, obj);
len = NISOBJLEN (2, obj);
- if (len == 0 && numstr[len - 1] != '\0')
+ if (len == 0 || numstr[len - 1] != '\0')
{
if (len >= room_left)
goto no_more_room;
@@ -98,7 +98,7 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw,
numstr = NISOBJVAL (3, obj);
len = NISOBJLEN (3, obj);
- if (len == 0 && numstr[len - 1] != '\0')
+ if (len == 0 || numstr[len - 1] != '\0')
{
if (len >= room_left)
goto no_more_room;
--
1.7.2.5
next prev parent reply other threads:[~2018-06-27 20:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-18 15:10 [PATCH] nisplus: Correct pwent parsing issue and resulting compilation error Maciej W. Rozycki
2018-06-18 15:25 ` Joseph Myers
2018-06-18 15:45 ` Maciej W. Rozycki
2018-06-18 15:49 ` Joseph Myers
2018-06-18 15:41 ` Andreas Schwab
2018-06-18 16:13 ` [PATCH v2] nisplus: Correct pwent parsing issue and resulting compilation error [BZ #23266] Maciej W. Rozycki
2018-06-18 19:44 ` DJ Delorie
2018-06-18 20:11 ` Maciej W. Rozycki
2018-06-18 20:40 ` DJ Delorie
2018-06-25 19:17 ` [PING][PATCH " Maciej W. Rozycki
2018-06-26 1:32 ` DJ Delorie
2018-06-27 20:14 ` Maciej W. Rozycki [this message]
2018-06-27 21:03 ` [committed v3] nisplus: Correct pwent parsing issue and resulting build " Joseph Myers
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=alpine.DEB.2.00.1806271622200.20622@tp.orcam.me.uk \
--to=macro@mips.com \
--cc=dj@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).