Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/common/lib/libprop add sized versions of the copyin ioctls
details: https://anonhg.NetBSD.org/src/rev/c096e358401f
branches: trunk
changeset: 350972:c096e358401f
user: christos <christos%NetBSD.org@localhost>
date: Sun Jan 29 00:16:42 2017 +0000
description:
add sized versions of the copyin ioctls
diffstat:
common/lib/libprop/prop_kern.c | 66 ++++++++++++++++++++++++++++++-----------
1 files changed, 48 insertions(+), 18 deletions(-)
diffs (130 lines):
diff -r 46bd66d25750 -r c096e358401f common/lib/libprop/prop_kern.c
--- a/common/lib/libprop/prop_kern.c Sun Jan 29 00:16:19 2017 +0000
+++ b/common/lib/libprop/prop_kern.c Sun Jan 29 00:16:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: prop_kern.c,v 1.20 2017/01/15 18:15:45 christos Exp $ */
+/* $NetBSD: prop_kern.c,v 1.21 2017/01/29 00:16:42 christos Exp $ */
/*-
* Copyright (c) 2006, 2009 The NetBSD Foundation, Inc.
@@ -401,13 +401,13 @@
static int
_prop_object_copyin(const struct plistref *pref, const prop_type_t type,
- prop_object_t *objp)
+ prop_object_t *objp, size_t lim)
{
prop_object_t obj = NULL;
char *buf;
int error;
- if (pref->pref_len >= prop_object_copyin_limit)
+ if (pref->pref_len >= lim)
return E2BIG;
/*
@@ -449,12 +449,12 @@
static int
_prop_object_copyin_ioctl(const struct plistref *pref, const prop_type_t type,
- const u_long cmd, prop_object_t *objp)
+ const u_long cmd, prop_object_t *objp, size_t lim)
{
if ((cmd & IOC_IN) == 0)
return (EFAULT);
- return _prop_object_copyin(pref, type, objp);
+ return _prop_object_copyin(pref, type, objp, lim);
}
/*
@@ -462,10 +462,17 @@
* Copy in an array passed as a syscall arg.
*/
int
+prop_array_copyin_size(const struct plistref *pref, prop_array_t *arrayp,
+ size_t lim)
+{
+ return _prop_object_copyin(pref, PROP_TYPE_ARRAY,
+ (prop_object_t *)arrayp, lim);
+}
+
+int
prop_array_copyin(const struct plistref *pref, prop_array_t *arrayp)
{
- return (_prop_object_copyin(pref, PROP_TYPE_ARRAY,
- (prop_object_t *)arrayp));
+ return prop_array_copyin_size(pref, arrayp, prop_object_copyin_limit);
}
/*
@@ -473,11 +480,18 @@
* Copy in a dictionary passed as a syscall arg.
*/
int
+prop_dictionary_copyin_size(const struct plistref *pref,
+ prop_dictionary_t *dictp, size_t lim)
+{
+ return _prop_object_copyin(pref, PROP_TYPE_DICTIONARY,
+ (prop_object_t *)dictp, lim);
+}
+
+int
prop_dictionary_copyin(const struct plistref *pref, prop_dictionary_t *dictp)
{
- return (_prop_object_copyin(pref, PROP_TYPE_DICTIONARY,
- (prop_object_t *)dictp));
-}
+ return prop_dictionary_copyin_size(pref, dictp,
+ prop_object_copyin_limit);
/*
@@ -485,11 +499,19 @@
* Copy in an array send with an ioctl.
*/
int
-prop_array_copyin_ioctl(const struct plistref *pref, const u_long cmd,
- prop_array_t *arrayp)
+prop_array_copyin_ioctl_size(const struct plistref *pref, const u_long cmd,
+ prop_array_t *arrayp, size_t lim)
{
- return (_prop_object_copyin_ioctl(pref, PROP_TYPE_ARRAY,
- cmd, (prop_object_t *)arrayp));
+ return _prop_object_copyin_ioctl(pref, PROP_TYPE_ARRAY,
+ cmd, (prop_object_t *)arrayp, lim);
+}
+
+int
+prop_array_copyin_ioctl(const struct plistref *pref, const u_long cmd,
+ prop_array_t *arrayp)
+{
+ return prop_array_copyin_ioctl(pref, cmd, arrayp,
+ prop_object_copyin_limit);
}
/*
@@ -497,11 +519,19 @@
* Copy in a dictionary sent with an ioctl.
*/
int
-prop_dictionary_copyin_ioctl(const struct plistref *pref, const u_long cmd,
- prop_dictionary_t *dictp)
+prop_dictionary_copyin_ioctl_size(const struct plistref *pref, const u_long cmd,
+ prop_dictionary_t *dictp, size_t lim)
{
- return (_prop_object_copyin_ioctl(pref, PROP_TYPE_DICTIONARY,
- cmd, (prop_object_t *)dictp));
+ return _prop_object_copyin_ioctl(pref, PROP_TYPE_DICTIONARY,
+ cmd, (prop_object_t *)dictp, lim);
+}
+
+int
+prop_dictionary_copyin_ioctl(const struct plistref *pref, const u_long cmd,
+ prop_dictionary_t *dictp)
+{
+ return prop_dictionary_copyin_ioctl(pref, cmd, dictp,
+ prop_object_copyin_limit);
}
static int
Home |
Main Index |
Thread Index |
Old Index