Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/netbsd32 Fix inverted logic, which leads to buffe...



details:   https://anonhg.NetBSD.org/src/rev/431eebec896a
branches:  trunk
changeset: 445767:431eebec896a
user:      maxv <maxv%NetBSD.org@localhost>
date:      Mon Nov 12 06:53:43 2018 +0000

description:
Fix inverted logic, which leads to buffer overflow. Detected by kASan.

diffstat:

 sys/compat/netbsd32/netbsd32_socket.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 5c8f8acdacae -r 431eebec896a sys/compat/netbsd32/netbsd32_socket.c
--- a/sys/compat/netbsd32/netbsd32_socket.c     Mon Nov 12 05:02:00 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32_socket.c     Mon Nov 12 06:53:43 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_socket.c,v 1.47 2018/05/13 00:04:23 christos Exp $    */
+/*     $NetBSD: netbsd32_socket.c,v 1.48 2018/11/12 06:53:43 maxv Exp $        */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_socket.c,v 1.47 2018/05/13 00:04:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_socket.c,v 1.48 2018/11/12 06:53:43 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -102,7 +102,7 @@
                }
 
                ktrkuser(mbuftypes[MT_CONTROL], cmsg, cmsg->cmsg_len);
-               error = copyout(&cmsg32, *q, MAX(i, sizeof(cmsg32)));
+               error = copyout(&cmsg32, *q, MIN(i, sizeof(cmsg32)));
                if (error)
                        return (error);
                if (i > CMSG32_LEN(0)) {



Home | Main Index | Thread Index | Old Index