]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nisplus: Correct pwent parsing issue and resulting build error [BZ #23266]
authorMaciej W. Rozycki <macro@mips.com>
Wed, 27 Jun 2018 20:12:16 +0000 (21:12 +0100)
committerMaciej W. Rozycki <macro@mips.com>
Wed, 27 Jun 2018 20:12:16 +0000 (21:12 +0100)
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.

ChangeLog
nis/nss_nisplus/nisplus-parser.c

index 056d3c4a437b64b0b078102575f8d6e015a6b6c8..eb1c35feb58ca32d23bfec635bd8a0d89efb5ebf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-06-27  Maciej W. Rozycki  <macro@mips.com>
+
+       [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.
+
 2018-06-27  Florian Weimer  <fweimer@redhat.com>
 
        [BZ #18023]
index 8dc021e73dc5356a57eb66338bf04ab9f0c215d3..d2b06334c2bc92a0cfdb047c4846a3497efe710f 100644 (file)
@@ -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;