From: Alejandro Colomar Date: Wed, 10 Dec 2025 14:21:15 +0000 (+0100) Subject: lib/utmp.c: get_current_utmp(): Use simple assignment instead of memcpy(3) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f754f6e0605abd0b912602452ab94cbe4fd2f10c;p=thirdparty%2Fshadow.git lib/utmp.c: get_current_utmp(): Use simple assignment instead of memcpy(3) memcpy(3) is overkill, and much more dangerous than simple assignment. Simple assignment adds type safety, and removes any possibility of buffer overflow due to accidentally specifying a wrong size. Signed-off-by: Alejandro Colomar --- diff --git a/lib/utmp.c b/lib/utmp.c index 00fac8ffa..678f9ac4f 100644 --- a/lib/utmp.c +++ b/lib/utmp.c @@ -187,7 +187,7 @@ get_current_utmp(pid_t main_pid) ut_copy = malloc_T(1, struct utmpx); if (ut_copy != NULL) - memcpy(ut_copy, ut, sizeof(*ut)); + *ut_copy = *ut; ut = ut_copy; }