Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/common Test for valid interface for ...
details: https://anonhg.NetBSD.org/src/rev/7c30f59dcd6b
branches: trunk
changeset: 318474:7c30f59dcd6b
user: roy <roy%NetBSD.org@localhost>
date: Thu Apr 26 08:11:18 2018 +0000
description:
Test for valid interface for ioctls that demand it.
Thanks to Robert Swindells for the patch.
diffstat:
sys/compat/common/uipc_syscalls_50.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diffs (49 lines):
diff -r f4ea5420d9f8 -r 7c30f59dcd6b sys/compat/common/uipc_syscalls_50.c
--- a/sys/compat/common/uipc_syscalls_50.c Thu Apr 26 07:48:21 2018 +0000
+++ b/sys/compat/common/uipc_syscalls_50.c Thu Apr 26 08:11:18 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_syscalls_50.c,v 1.4 2018/04/12 18:50:13 christos Exp $ */
+/* $NetBSD: uipc_syscalls_50.c,v 1.5 2018/04/26 08:11:18 roy Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_50.c,v 1.4 2018/04/12 18:50:13 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_50.c,v 1.5 2018/04/26 08:11:18 roy Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -63,10 +63,19 @@
struct ifnet *ifp;
int error;
- ifp = ifunit(ifdr->ifdr_name);
- if (ifp == NULL)
- return ENXIO;
+ /* Validate arguments. */
+ switch (cmd) {
+ case SIOCGIFDATA:
+ case SIOCZIFDATA:
+ ifp = ifunit(ifdr->ifdr_name);
+ if (ifp == NULL)
+ return ENXIO;
+ break;
+ default:
+ return ENOSYS;
+ }
+ /* Do work. */
switch (cmd) {
case SIOCGIFDATA:
ifdatan2o(&ifdr->ifdr_data, &ifp->if_data);
@@ -91,6 +100,7 @@
return 0;
default:
+ /* Impossible due to above validation, but makes gcc happy. */
return ENOSYS;
}
}
Home |
Main Index |
Thread Index |
Old Index