This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Replace strncpy with memccpy to fix -Wstringop-truncation.
- From: Khem Raj <raj dot khem at gmail dot com>
- To: libc-alpha at sourceware dot org
- Cc: Khem Raj <raj dot khem at gmail dot com>
- Date: Thu, 22 Mar 2018 18:07:29 -0700
- Subject: [PATCH] Replace strncpy with memccpy to fix -Wstringop-truncation.
* nis/nss_nisplus/nisplus-parser.c: Replace strncpy with memcpy to
avoid -Wstringop-truncation.
---
2018-03-22 Khem Raj <raj.khem@gmail.com>
* nis/nss_nisplus/nisplus-parser.c (_nss_nisplus_parse_pwent): Replace
strncpy with memcpy to avoid -Wstringop-truncation.
nis/nss_nisplus/nisplus-parser.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/nis/nss_nisplus/nisplus-parser.c b/nis/nss_nisplus/nisplus-parser.c
index 8dc021e73d..b53284f889 100644
--- a/nis/nss_nisplus/nisplus-parser.c
+++ b/nis/nss_nisplus/nisplus-parser.c
@@ -87,7 +87,7 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw,
if (len >= room_left)
goto no_more_room;
- strncpy (first_unused, numstr, len);
+ memcpy (first_unused, numstr, len);
first_unused[len] = '\0';
numstr = first_unused;
}
@@ -103,7 +103,7 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw,
if (len >= room_left)
goto no_more_room;
- strncpy (first_unused, numstr, len);
+ memcpy (first_unused, numstr, len);
first_unused[len] = '\0';
numstr = first_unused;
}
--
2.16.2