Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern When converting out of range 64bit sysctl values to...
details: https://anonhg.NetBSD.org/src/rev/4b54caeba95f
branches: trunk
changeset: 327197:4b54caeba95f
user: dsl <dsl%NetBSD.org@localhost>
date: Sat Mar 01 17:27:48 2014 +0000
description:
When converting out of range 64bit sysctl values to 'int' (because of
an 'int' sized read) don't assume that sizeof (int) is 4.
diffstat:
sys/kern/kern_sysctl.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diffs (42 lines):
diff -r 7c712a43f405 -r 4b54caeba95f sys/kern/kern_sysctl.c
--- a/sys/kern/kern_sysctl.c Sat Mar 01 16:59:41 2014 +0000
+++ b/sys/kern/kern_sysctl.c Sat Mar 01 17:27:48 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sysctl.c,v 1.247 2014/02/27 22:50:52 dsl Exp $ */
+/* $NetBSD: kern_sysctl.c,v 1.248 2014/03/01 17:27:48 dsl Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.247 2014/02/27 22:50:52 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.248 2014/03/01 17:27:48 dsl Exp $");
#include "opt_defcorename.h"
#include "ksyms.h"
@@ -1513,7 +1513,7 @@
switch (SYSCTL_TYPE(rnode->sysctl_flags)) {
case CTLTYPE_INT:
/* Allow for 64bit read of 32bit value */
- if (*oldlenp == sizeof (uint64_t)) {
+ if (*oldlenp != sz && *oldlenp == sizeof (uint64_t)) {
qval = *(int *)d;
d_out = &qval;
sz = sizeof (uint64_t);
@@ -1521,9 +1521,12 @@
break;
case CTLTYPE_QUAD:
/* Allow for 32bit read of 64bit value */
- if (*oldlenp == sizeof (int)) {
+ if (*oldlenp != sz && *oldlenp == sizeof (int)) {
qval = *(uint64_t *)d;
- ival = qval < 0x100000000 ? qval : 0xffffffff;
+ ival = qval;
+ /* Replace out of range values with -1 */
+ if (ival != qval)
+ ival = -1;
d_out = &ival;
sz = sizeof (int);
}
Home |
Main Index |
Thread Index |
Old Index