Module Name:    src
Committed By:   mlelstv
Date:           Tue Dec 31 12:58:02 UTC 2013

Modified Files:
        src/lib/libutil: sockaddr_snprintf.c

Log Message:
Use output buffer size to limit copy-out of sun_path. Otherwise you may
get a buffer overflow with strlcpy :)


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libutil/sockaddr_snprintf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/sockaddr_snprintf.c
diff -u src/lib/libutil/sockaddr_snprintf.c:1.10 src/lib/libutil/sockaddr_snprintf.c:1.11
--- src/lib/libutil/sockaddr_snprintf.c:1.10	Fri Jun  7 17:23:26 2013
+++ src/lib/libutil/sockaddr_snprintf.c	Tue Dec 31 12:58:02 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: sockaddr_snprintf.c,v 1.10 2013/06/07 17:23:26 christos Exp $	*/
+/*	$NetBSD: sockaddr_snprintf.c,v 1.11 2013/12/31 12:58:02 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sockaddr_snprintf.c,v 1.10 2013/06/07 17:23:26 christos Exp $");
+__RCSID("$NetBSD: sockaddr_snprintf.c,v 1.11 2013/12/31 12:58:02 mlelstv Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -145,7 +145,7 @@ sockaddr_snprintf(char * const sbuf, con
 		break;
 	case AF_LOCAL:
 		sun = ((const struct sockaddr_un *)(const void *)sa);
-		(void)strlcpy(addr = abuf, sun->sun_path, SUN_LEN(sun));
+		(void)strlcpy(addr = abuf, sun->sun_path, sizeof(abuf));
 		break;
 	case AF_INET:
 		sin4 = ((const struct sockaddr_in *)(const void *)sa);

Reply via email to