]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/utmp.c: get_current_utmp(): Use simple assignment instead of memcpy(3)
authorAlejandro Colomar <alx@kernel.org>
Wed, 10 Dec 2025 14:21:15 +0000 (15:21 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Tue, 17 Feb 2026 09:45:39 +0000 (10:45 +0100)
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 <alx@kernel.org>
lib/utmp.c

index 00fac8ffa9b854d648e801dae4d075c0042d759a..678f9ac4f8197b60088db97c7f9d3dd1cac9a0fc 100644 (file)
@@ -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;
        }