]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/utmp.c: get_current_utmp(): Use memdup_T() instead of its pattern
authorAlejandro Colomar <alx@kernel.org>
Wed, 16 Jul 2025 15:44:26 +0000 (17:44 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Tue, 17 Feb 2026 09:45:39 +0000 (10:45 +0100)
Reviewed-by: "Evgeny Grin (Karlson2k)" <k2k@drgrin.dev>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/utmp.c

index 678f9ac4f8197b60088db97c7f9d3dd1cac9a0fc..f5fd2a57ef2c4e9cc9765cbc7b587ddb1ed814af 100644 (file)
@@ -36,6 +36,7 @@
 #include "string/strcmp/strneq.h"
 #include "string/strcmp/strprefix.h"
 #include "string/strcpy/strncpy.h"
+#include "string/strdup/memdup.h"
 #include "string/strdup/strdup.h"
 #include "string/strdup/strndup.h"
 
@@ -182,14 +183,8 @@ get_current_utmp(pid_t main_pid)
        if (NULL == ut)
                ut = ut_by_pid ?: ut_by_line;
 
-       if (NULL != ut) {
-               struct utmpx  *ut_copy;
-
-               ut_copy = malloc_T(1, struct utmpx);
-               if (ut_copy != NULL)
-                       *ut_copy = *ut;
-               ut = ut_copy;
-       }
+       if (NULL != ut)
+               ut = memdup_T(ut, struct utmpx);
 
        free(ut_by_line);
        free(ut_by_pid);