From 3c09e40a1fe9ccff4cf3d6a1e65c2bc3eba33b1e Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Mon, 13 May 2024 15:47:19 +0200 Subject: [PATCH] lib/utmp.c: Use XSTRNDUP() instead of its pattern Signed-off-by: Alejandro Colomar --- lib/utmp.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/utmp.c b/lib/utmp.c index d01a31166..7834e7a3c 100644 --- a/lib/utmp.c +++ b/lib/utmp.c @@ -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 } -- 2.47.3