summaryrefslogtreecommitdiff
path: root/sys/compat/linux
diff options
context:
space:
mode:
authortron <tron@NetBSD.org>1999-12-04 22:08:36 +0000
committertron <tron@NetBSD.org>1999-12-04 22:08:36 +0000
commitf8df357a47ebf0f35398aa9cc0d4fdb6e30ddd1d (patch)
treec9f154a05d7350d5a79a3d83a8307f6869f03db8 /sys/compat/linux
parent5bc798bb826a0cb2e514690b825048efa5923070 (diff)
Add bound checks in emulation of signal(2) and return SIG_ERR on failure.
This fixes a part of PR kern/8904 by Dave Sainty.
Diffstat (limited to 'sys/compat/linux')
-rw-r--r--sys/compat/linux/common/linux_sig_notalpha.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/sys/compat/linux/common/linux_sig_notalpha.c b/sys/compat/linux/common/linux_sig_notalpha.c
index 12692da3e22..2b86a948727 100644
--- a/sys/compat/linux/common/linux_sig_notalpha.c
+++ b/sys/compat/linux/common/linux_sig_notalpha.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_sig_notalpha.c,v 1.18 1998/10/07 23:05:09 erh Exp $ */
+/* $NetBSD: linux_sig_notalpha.c,v 1.19 1999/12/04 22:08:36 tron Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -77,17 +77,21 @@ linux_sys_signal(p, v, retval)
syscallarg(linux_handler_t) handler;
} */ *uap = v;
struct sigaction nbsa, obsa;
- int error;
+ int error, signum;
+
+ *retval = -1;
+ signum = SCARG(uap, sig);
+ if (signum < 0 || signum >= LINUX__NSIG)
+ return (EINVAL);
nbsa.sa_handler = SCARG(uap, handler);
sigemptyset(&nbsa.sa_mask);
nbsa.sa_flags = SA_RESETHAND | SA_NODEFER;
- error = sigaction1(p, linux_to_native_sig[SCARG(uap, sig)],
+ error = sigaction1(p, linux_to_native_sig[signum],
&nbsa, &obsa);
- if (error)
- return (error);
- *retval = (int)obsa.sa_handler;
- return (0);
+ if (error == 0)
+ *retval = (int)obsa.sa_handler;
+ return (error);
}
@@ -167,3 +171,4 @@ linux_sys_pause(p, v, retval)
return (sigsuspend1(p, 0));
}
+