Cast function pointers to uintfptr_t before casting them to u_long.

Hopefully caddr_t is large enough to hold function pointers.

Cast object pointers to uintptr_t before casting them to u_long.

Types are wronger than usual for the PT_READ_U case.  ptrace() can
only return ints, but longs are accessed.
This commit is contained in:
Bruce Evans 1998-07-15 04:43:49 +00:00
parent 3bc25faee6
commit 6a206dd96a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=37655

View file

@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: sys_process.c,v 1.37 1998/05/19 00:00:12 tegge Exp $
* $Id: sys_process.c,v 1.38 1998/06/07 17:11:39 dfr Exp $
*/
#include <sys/param.h>
@ -338,7 +338,8 @@ ptrace(curp, uap)
if (uap->addr != (caddr_t)1) {
fill_eproc (p, &p->p_addr->u_kproc.kp_eproc);
if ((error = ptrace_set_pc (p, (u_long)uap->addr))) {
if ((error = ptrace_set_pc (p,
(u_long)(uintfptr_t)uap->addr))) {
PRELE(p);
return error;
}
@ -384,7 +385,7 @@ ptrace(curp, uap)
iov.iov_len = sizeof(int);
uio.uio_iov = &iov;
uio.uio_iovcnt = 1;
uio.uio_offset = (off_t)(u_long)uap->addr;
uio.uio_offset = (off_t)(uintptr_t)uap->addr;
uio.uio_resid = sizeof(int);
uio.uio_segflg = UIO_SYSSPACE; /* ie: the uap */
uio.uio_rw = write ? UIO_WRITE : UIO_READ;
@ -406,7 +407,7 @@ ptrace(curp, uap)
return (error);
case PT_READ_U:
if ((u_long)uap->addr > (UPAGES * PAGE_SIZE - sizeof(long))) {
if ((uintptr_t)uap->addr > UPAGES * PAGE_SIZE - sizeof(long)) {
return EFAULT;
}
if (ptrace_read_u_check(p,(vm_offset_t) uap->addr,
@ -419,7 +420,8 @@ ptrace(curp, uap)
if (p->p_flag & P_INMEM) {
p->p_addr->u_kproc.kp_proc = *p;
fill_eproc (p, &p->p_addr->u_kproc.kp_eproc);
curp->p_retval[0] = *(long*)((u_long)p->p_addr + (u_long)uap->addr);
curp->p_retval[0] = *(long *)
((uintptr_t)p->p_addr + (uintptr_t)uap->addr);
} else {
curp->p_retval[0] = 0;
error = EFAULT;