From dfc32e5b3ece9b33dab339341ebeab4edad5023c Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 30 Jul 2019 12:42:07 -0600 Subject: [PATCH] Disable stringop-truncation false positive warnings on gcc 8. Strings in struct utmp/utmpx are not guaranteed to be NUL-terminated. --- src/utmp.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utmp.c b/src/utmp.c index 3afbcb3fc..c8341cbed 100644 --- a/src/utmp.c +++ b/src/utmp.c @@ -52,6 +52,14 @@ #include "sudo.h" #include "sudo_exec.h" +/* + * GCC 8 warns about strncpy() where the size field is the size of the buffer. + * However, strings in utmp may not be NUL terminated so this usage is correct. + */ +#if __GNUC_PREREQ__(8, 0) +# pragma GCC diagnostic ignored "-Wstringop-truncation" +#endif + /* * Simplify handling of different utmp types. */ -- 2.40.0