This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch master in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=9cc48e639eba62c41beb3b137b9cf8704dfc89ca commit 9cc48e639eba62c41beb3b137b9cf8704dfc89ca Author: Guillem Jover <[email protected]> AuthorDate: Thu Jul 12 05:21:52 2018 +0200 libdpkg: Use memccpy() instead of strncpy() We were using strncpy() here as originally intended, to copy a string into a struct member without copying the NUL-terminator. But now gcc warns about the intended truncation, which might catch some people unexpectedly. Switch to use memccpy() which has similar semantics, but is more explicit. Warned-by: gcc-8 --- debian/changelog | 1 + lib/dpkg/t/t-ar.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 28568a5c4..661f739c9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -159,6 +159,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium * Code internals: - Do not use stringy eval to define different sub implementations, just assign an anonymous sub to the typeglob. + - Use memccpy() instead of strncpy() to quiesce a gcc-8 warning. * Build system: - Set distribution tarball format to ustar, instead of default v7 format. - Mark PO4A and POD2MAN as precious variables. diff --git a/lib/dpkg/t/t-ar.c b/lib/dpkg/t/t-ar.c index 28b5e38f3..88e93872a 100644 --- a/lib/dpkg/t/t-ar.c +++ b/lib/dpkg/t/t-ar.c @@ -21,6 +21,8 @@ #include <config.h> #include <compat.h> +#include <string.h> + #include <dpkg/test.h> #include <dpkg/ar.h> @@ -29,11 +31,11 @@ test_ar_normalize_name(void) { struct dpkg_ar_hdr arh; - strncpy(arh.ar_name, "member-name/ ", sizeof(arh.ar_name)); + memccpy(arh.ar_name, "member-name/ ", '\0', sizeof(arh.ar_name)); dpkg_ar_normalize_name(&arh); test_str(arh.ar_name, ==, "member-name"); - strncpy(arh.ar_name, "member-name ", sizeof(arh.ar_name)); + memccpy(arh.ar_name, "member-name ", '\0', sizeof(arh.ar_name)); dpkg_ar_normalize_name(&arh); test_str(arh.ar_name, ==, "member-name"); } -- Dpkg.Org's dpkg

