Disable stringop-truncation false positive warnings on gcc 8.
authorTodd C. Miller <Todd.Miller@sudo.ws>
Tue, 30 Jul 2019 18:42:07 +0000 (12:42 -0600)
committerTodd C. Miller <Todd.Miller@sudo.ws>
Tue, 30 Jul 2019 18:42:07 +0000 (12:42 -0600)
Strings in struct utmp/utmpx are not guaranteed to be NUL-terminated.

src/utmp.c

index 3afbcb3fcff2d9506e65d9a64e0a411e73bbd7ae..c8341cbed98d88a58f30f7f84008ac8699646c7c 100644 (file)
 #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.
  */