lib: remove last uses of sockunion_su2str()

Use of this function is prone to memory leaks.

This fixes a memory accounting bug for vty denied connections.

Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net>
Signed-off-by: David Lamparter <equinox@diac24.net>
diff --git a/lib/vty.c b/lib/vty.c
index 9a4efe6..70bf564 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -1612,13 +1612,16 @@
 static struct vty *
 vty_create (int vty_sock, union sockunion *su)
 {
+  char buf[SU_ADDRSTRLEN];
   struct vty *vty;
 
+  sockunion2str(su, buf, SU_ADDRSTRLEN);
+
   /* Allocate new vty structure and set up default values. */
   vty = vty_new ();
   vty->fd = vty_sock;
   vty->type = VTY_TERM;
-  vty->address = sockunion_su2str (su);
+  strcpy (vty->address, buf);
   if (no_password_check)
     {
       if (restricted_mode)
@@ -1693,7 +1696,7 @@
   int accept_sock;
   struct prefix *p = NULL;
   struct access_list *acl = NULL;
-  char *bufp;
+  char buf[SU_ADDRSTRLEN];
 
   accept_sock = THREAD_FD (thread);
 
@@ -1719,10 +1722,8 @@
       if ((acl = access_list_lookup (AFI_IP, vty_accesslist_name)) &&
 	  (access_list_apply (acl, p) == FILTER_DENY))
 	{
-	  char *buf;
 	  zlog (NULL, LOG_INFO, "Vty connection refused from %s",
-		(buf = sockunion_su2str (&su)));
-	  free (buf);
+		sockunion2str (&su, buf, SU_ADDRSTRLEN));
 	  close (vty_sock);
 	  
 	  /* continue accepting connections */
@@ -1741,10 +1742,8 @@
       if ((acl = access_list_lookup (AFI_IP6, vty_ipv6_accesslist_name)) &&
 	  (access_list_apply (acl, p) == FILTER_DENY))
 	{
-	  char *buf;
 	  zlog (NULL, LOG_INFO, "Vty connection refused from %s",
-		(buf = sockunion_su2str (&su)));
-	  free (buf);
+		sockunion2str (&su, buf, SU_ADDRSTRLEN));
 	  close (vty_sock);
 	  
 	  /* continue accepting connections */
@@ -1767,9 +1766,7 @@
 	  safe_strerror (errno));
 
   zlog (NULL, LOG_INFO, "Vty connection from %s",
-    (bufp = sockunion_su2str (&su)));
-  if (bufp)
-    XFREE (MTYPE_TMP, bufp);
+	sockunion2str (&su, buf, SU_ADDRSTRLEN));
 
   vty_create (vty_sock, &su);
 
@@ -2193,8 +2190,6 @@
   if (vty->fd > 0)
     close (vty->fd);
 
-  if (vty->address)
-    XFREE (MTYPE_TMP, vty->address);
   if (vty->buf)
     XFREE (MTYPE_VTY, vty->buf);