Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libutil Use output buffer size to limit copy-out of sun_...



details:   https://anonhg.NetBSD.org/src/rev/b668de16af04
branches:  trunk
changeset: 325599:b668de16af04
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Tue Dec 31 12:58:02 2013 +0000

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

diffstat:

 lib/libutil/sockaddr_snprintf.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r eeb7ebaabe63 -r b668de16af04 lib/libutil/sockaddr_snprintf.c
--- a/lib/libutil/sockaddr_snprintf.c   Tue Dec 31 09:10:43 2013 +0000
+++ b/lib/libutil/sockaddr_snprintf.c   Tue Dec 31 12:58:02 2013 +0000
@@ -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 @@
                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);



Home | Main Index | Thread Index | Old Index