From 58a5adf9065e08beefad79993da9424e98fd3b8d Mon Sep 17 00:00:00 2001 From: Steve Grubb Date: Fri, 18 Mar 2022 15:35:02 -0400 Subject: [PATCH] logoutd.c: fixed compile error with -Werror gcc -DHAVE_CONFIG_H -I. -I.. -I../lib -I../libmisc -DLOCALEDIR=\"/usr/share/locale\" -pipe -frecord-gcc-switches -Wall -g -O2 -Werror -Wno-error=address -Wno-error=cpp -DEXTRA_CHECK_HOME_DIR -c -o logoutd.o logoutd.c logoutd.c: In function 'main': logoutd.c:248:25: error: 'strcat' argument 2 declared attribute 'nonstring' [-Werror=stringop-overread] 248 | strcat (tty_name, ut->ut_line); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/utmp.h:29, from ../lib/prototypes.h:52, from logoutd.c:42: /usr/include/bits/utmp.h:62:8: note: argument 'ut_line' declared here 62 | char ut_line[UT_LINESIZE] | ^~~~~~~ cc1: all warnings being treated as errors make[2]: *** [Makefile:943: logoutd.o] Error 1 ut_line is declared as a nonstring in bits/utmp.h. It might not be NUL terminated. Limit how much it copies to the size of the array. asheplyakov: improved the commit message --- shadow/src/logoutd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shadow/src/logoutd.c b/shadow/src/logoutd.c index 3fcb41f..1aef1c5 100644 --- a/shadow/src/logoutd.c +++ b/shadow/src/logoutd.c @@ -245,7 +245,7 @@ int main (int argc, char **argv) tty_name[0] = '\0'; } - strcat (tty_name, ut->ut_line); + strncat (tty_name, ut->ut_line, UT_LINESIZE); #ifndef O_NOCTTY #define O_NOCTTY 0 #endif -- 2.33.3