From 3d2d88029b29d6e1c53220ad275ba8ba2dedd89e Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 29 Oct 2011 11:13:32 -0700 Subject: AuthAudit: clean up string handling calls The extra "out" pointer to redirect writes to the array isn't needed since the removal of LBX (commit a9ed5a87902a), and eliminating it allows more logical use of sizeof(addr) in length-checked strlcpy & snprintf calls to write to it. Signed-off-by: Alan Coopersmith Reviewed-by: Jeremy Huddleston --- os/connection.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/os/connection.c b/os/connection.c index b339f4e96..957b928dd 100644 --- a/os/connection.c +++ b/os/connection.c @@ -499,7 +499,6 @@ AuthAudit (ClientPtr client, Bool letin, unsigned int proto_n, char *auth_proto, int auth_id) { char addr[128]; - char *out = addr; char client_uid_string[64]; LocalClientCredRec *lcc; #ifdef XSERVER_DTRACE @@ -508,7 +507,7 @@ AuthAudit (ClientPtr client, Bool letin, #endif if (!len) - strcpy(out, "local host"); + strlcpy(addr, "local host", sizeof(addr)); else switch (saddr->sa_family) { @@ -516,11 +515,11 @@ AuthAudit (ClientPtr client, Bool letin, #if defined(UNIXCONN) || defined(LOCALCONN) case AF_UNIX: #endif - strcpy(out, "local host"); + strlcpy(addr, "local host", sizeof(addr)); break; #if defined(TCPCONN) || defined(STREAMSCONN) case AF_INET: - sprintf(out, "IP %s", + snprintf(addr, sizeof(addr), "IP %s", inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr)); break; #if defined(IPv6) && defined(AF_INET6) @@ -528,13 +527,13 @@ AuthAudit (ClientPtr client, Bool letin, char ipaddr[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, &((struct sockaddr_in6 *) saddr)->sin6_addr, ipaddr, sizeof(ipaddr)); - sprintf(out, "IP %s", ipaddr); + snprintf(addr, sizeof(addr), "IP %s", ipaddr); } break; #endif #endif default: - strcpy(out, "unknown address"); + strlcpy(addr, "unknown address", sizeof(addr)); } if (GetLocalClientCreds(client, &lcc) != -1) { -- cgit v1.2.3