From: Alejandro Colomar Date: Mon, 13 May 2024 13:48:53 +0000 (+0200) Subject: lib/utmp.c: prepare_utmp(): Use xstrdup() instead of its pattern X-Git-Tag: 4.17.0-rc1~183 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=103ffc5b1d139409691fcc6b243d8d669a32085b;p=thirdparty%2Fshadow.git lib/utmp.c: prepare_utmp(): Use xstrdup() instead of its pattern Signed-off-by: Alejandro Colomar --- diff --git a/lib/utmp.c b/lib/utmp.c index 7834e7a3c..40c32c18d 100644 --- a/lib/utmp.c +++ b/lib/utmp.c @@ -250,16 +250,12 @@ prepare_utmp(const char *name, const char *line, const char *host, - if ( (NULL != host) - && ('\0' != host[0])) { - hostname = XMALLOC(strlen(host) + 1, char); - strcpy (hostname, host); + if (NULL != host && '\0' != host[0]) + hostname = xstrdup(host); #if defined(HAVE_STRUCT_UTMPX_UT_HOST) - } else if ( (NULL != ut) - && ('\0' != ut->ut_host[0])) { + else if (NULL != ut && '\0' != ut->ut_host[0]) hostname = XSTRNDUP(ut->ut_host); #endif - } if (strncmp(line, "/dev/", 5) == 0) { line += 5;