Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/common - make sure size is not used uninitialized
details: https://anonhg.NetBSD.org/src/rev/4250a0f55252
branches: trunk
changeset: 744356:4250a0f55252
user: christos <christos%NetBSD.org@localhost>
date: Thu Jan 30 14:07:40 2020 +0000
description:
- make sure size is not used uninitialized
- limit size range
- fix type botch for "size"
from maxv@
diffstat:
sys/compat/common/kern_info_43.c | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diffs (41 lines):
diff -r dc30942ea7db -r 4250a0f55252 sys/compat/common/kern_info_43.c
--- a/sys/compat/common/kern_info_43.c Thu Jan 30 13:56:48 2020 +0000
+++ b/sys/compat/common/kern_info_43.c Thu Jan 30 14:07:40 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_info_43.c,v 1.38 2020/01/02 15:42:26 thorpej Exp $ */
+/* $NetBSD: kern_info_43.c,v 1.39 2020/01/30 14:07:40 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1991, 1993
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_info_43.c,v 1.38 2020/01/02 15:42:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_info_43.c,v 1.39 2020/01/30 14:07:40 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -172,11 +172,19 @@
syscallarg(int) arg;
} */
int error, name[6];
+ int isize;
size_t size;
- if (SCARG(uap, size) && (error = copyin((void *)SCARG(uap, size),
- (void *)&size, sizeof(size))))
- return (error);
+ if (!SCARG(uap, size))
+ return EINVAL;
+
+ if ((error = copyin(SCARG(uap, size), &isize, sizeof(isize))) != 0)
+ return error;
+
+ if (isize < 0 || isize > 4096)
+ return EINVAL;
+
+ size = isize;
switch (SCARG(uap, op) & 0xff00) {
Home |
Main Index |
Thread Index |
Old Index