]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/utmp.c: Use XSTRNDUP() instead of its pattern
authorAlejandro Colomar <alx@kernel.org>
Mon, 13 May 2024 13:47:19 +0000 (15:47 +0200)
committerSerge Hallyn <serge@hallyn.com>
Tue, 2 Jul 2024 02:40:11 +0000 (21:40 -0500)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/utmp.c

index d01a31166851494540323e2969b93e81bef55c33..7834e7a3c36b0e8a697bfd943dbcf5e03e9efc38 100644 (file)
@@ -26,7 +26,7 @@
 #include "sizeof.h"
 #include "string/strcpy/strncpy.h"
 #include "string/strcpy/strtcpy.h"
-#include "string/strcpy/zustr2stp.h"
+#include "string/strdup/xstrndup.h"
 
 #ident "$Id$"
 
@@ -185,11 +185,7 @@ get_session_host(char **out)
 
 #if defined(HAVE_STRUCT_UTMPX_UT_HOST)
        if ((ut != NULL) && (ut->ut_host[0] != '\0')) {
-               char  *hostname;
-
-               hostname = XMALLOC(sizeof(ut->ut_host) + 1, char);
-               ZUSTR2STP(hostname, ut->ut_host);
-               *out = hostname;
+               *out = XSTRNDUP(ut->ut_host);
                free (ut);
        } else {
                *out = NULL;
@@ -261,8 +257,7 @@ prepare_utmp(const char *name, const char *line, const char *host,
 #if defined(HAVE_STRUCT_UTMPX_UT_HOST)
        } else if (   (NULL != ut)
                   && ('\0' != ut->ut_host[0])) {
-               hostname = XMALLOC(NITEMS(ut->ut_host) + 1, char);
-               ZUSTR2STP(hostname, ut->ut_host);
+               hostname = XSTRNDUP(ut->ut_host);
 #endif
        }