From 01d77786da675a9cdb03bb641762bc603082261e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tim=20R=C3=BChsen?= <tim.ruehsen@gmx.de>
Date: Sat, 29 Feb 2020 19:42:00 +0100
Subject: [PATCH 50/60] telnet/commands.c: Use strdup instead malloc+strcpy

---
 telnet/commands.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/telnet/commands.c b/telnet/commands.c
index cd0c75ab..5003ee07 100644
--- a/telnet/commands.c
+++ b/telnet/commands.c
@@ -2585,10 +2585,8 @@ tn (int argc, char *argv[])
     }
 
   free (hostname);
-  hostname = malloc (strlen (hostp) + 1);
-  if (hostname)
-    strcpy (hostname, hostp);
-  else
+  hostname = strdup (hostp);
+  if (!hostname)
     {
       printf ("Can't allocate memory to copy hostname\n");
       return 0;
-- 
2.26.0.292.g33ef6b2f38

