Module Name:    src
Committed By:   christos
Date:           Sun Jan 29 00:16:42 UTC 2017

Modified Files:
        src/common/lib/libprop: prop_kern.c

Log Message:
add sized versions of the copyin ioctls


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/common/lib/libprop/prop_kern.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libprop/prop_kern.c
diff -u src/common/lib/libprop/prop_kern.c:1.20 src/common/lib/libprop/prop_kern.c:1.21
--- src/common/lib/libprop/prop_kern.c:1.20	Sun Jan 15 13:15:45 2017
+++ src/common/lib/libprop/prop_kern.c	Sat Jan 28 19:16:42 2017
@@ -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 @@ prop_kern_init(void)
 
 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 @@ _prop_object_copyin(const struct plistre
 
 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 @@ _prop_object_copyin_ioctl(const struct p
  *	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,23 +480,38 @@ prop_array_copyin(const struct plistref 
  *	Copy in a dictionary passed as a syscall arg.
  */
 int
-prop_dictionary_copyin(const struct plistref *pref, prop_dictionary_t *dictp)
+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));
+	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_dictionary_copyin_size(pref, dictp,
+	    prop_object_copyin_limit);
+
 
 /*
  * prop_array_copyin_ioctl --
  *	Copy in an array send with an ioctl.
  */
 int
+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, lim);
+}
+
+int
 prop_array_copyin_ioctl(const struct plistref *pref, const u_long cmd,
-			prop_array_t *arrayp)
+    prop_array_t *arrayp)
 {
-	return (_prop_object_copyin_ioctl(pref, PROP_TYPE_ARRAY,
-					  cmd, (prop_object_t *)arrayp));
+	return prop_array_copyin_ioctl(pref, cmd, arrayp,
+	    prop_object_copyin_limit);
 }
 
 /*
@@ -497,11 +519,19 @@ prop_array_copyin_ioctl(const struct pli
  *	Copy in a dictionary sent with an ioctl.
  */
 int
+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, lim);
+}
+
+int
 prop_dictionary_copyin_ioctl(const struct plistref *pref, const u_long cmd,
-			     prop_dictionary_t *dictp)
+    prop_dictionary_t *dictp)
 {
-	return (_prop_object_copyin_ioctl(pref, PROP_TYPE_DICTIONARY,
-					  cmd, (prop_object_t *)dictp));
+    return prop_dictionary_copyin_ioctl(pref, cmd, dictp,
+	prop_object_copyin_limit);
 }
 
 static int

Reply via email to