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.
This commit is contained in:
tron 1999-12-04 22:08:36 +00:00
parent 5bc798bb82
commit f8df357a47
1 changed files with 12 additions and 7 deletions

View File

@ -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));
}