Source-Changes-HG archive

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

[src/trunk]: src/sys/kern validate unix socker buffer size and truncate path ...



details:   https://anonhg.NetBSD.org/src/rev/82dae2055017
branches:  trunk
changeset: 955933:82dae2055017
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sat Oct 17 09:45:20 2020 +0000

description:
validate unix socker buffer size and truncate path to prevent overflow.

diffstat:

 sys/kern/uipc_domain.c |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r d21f273c9744 -r 82dae2055017 sys/kern/uipc_domain.c
--- a/sys/kern/uipc_domain.c    Sat Oct 17 09:42:35 2020 +0000
+++ b/sys/kern/uipc_domain.c    Sat Oct 17 09:45:20 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_domain.c,v 1.106 2018/12/27 07:56:43 maxv Exp $   */
+/*     $NetBSD: uipc_domain.c,v 1.107 2020/10/17 09:45:20 mlelstv Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.106 2018/12/27 07:56:43 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.107 2020/10/17 09:45:20 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/socket.h>
@@ -412,6 +412,13 @@
 sun_print(char *buf, size_t len, const void *v)
 {
        const struct sockaddr_un *sun = v;
+       size_t plen;
+
+       KASSERT(sun->sun_len >= offsetof(struct sockaddr_un, sun_path[0]));
+       plen = sun->sun_len - offsetof(struct sockaddr_un, sun_path[0]);
+
+       len = MIN(len, plen);
+
        return snprintf(buf, len, "%s", sun->sun_path);
 }
 



Home | Main Index | Thread Index | Old Index