From 1055bedbed42dc176468b45b4f167a752ed8868f Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Sun, 4 Dec 2022 16:28:22 -0800 Subject: [PATCH] pw: Don't return a pointer to an on-stack buffer from grp_set_passwd. Make 'line' static to move it to .bss instead as that pattern is used elsewhere in pw(8) (e.g. the static buffer in pw_pwcrypt). Reported by: GCC -Wdangling-pointer Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D37534 --- usr.sbin/pw/pw_group.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.sbin/pw/pw_group.c b/usr.sbin/pw/pw_group.c index 1f5979a5dd0..838bafa3e8b 100644 --- a/usr.sbin/pw/pw_group.c +++ b/usr.sbin/pw/pw_group.c @@ -55,7 +55,8 @@ grp_set_passwd(struct group *grp, bool update, int fd, bool precrypted) int b; int istty; struct termios t, n; - char *p, line[256]; + static char line[256]; + char *p; if (fd == -1) return; -- 2.45.2