]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/utmp.c: prepare_utmp(): Use xstrdup() instead of its pattern
authorAlejandro Colomar <alx@kernel.org>
Mon, 13 May 2024 13:48:53 +0000 (15:48 +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 7834e7a3c36b0e8a697bfd943dbcf5e03e9efc38..40c32c18d6e81b9462c567ef2877e5a97bcf7022 100644 (file)
@@ -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;