From e1859436f111d40e0b499d357ea4f660ce740b12 Mon Sep 17 00:00:00 2001 From: pk Date: Thu, 1 Jun 2000 18:30:03 +0000 Subject: [PATCH] Fix lossage when transferring a pointer value into an off_t var. --- sys/kern/kern_sysctl.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 2fb531011934..04cab60b9f1f 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sysctl.c,v 1.67 2000/06/01 13:36:51 simonb Exp $ */ +/* $NetBSD: kern_sysctl.c,v 1.68 2000/06/01 18:30:03 pk Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -1335,6 +1335,7 @@ sysctl_procargs(name, namelen, where, sizep, up) pid_t pid; int nargv, type, error, i; char *arg; + char *tmp; if (namelen != 2) return (EINVAL); @@ -1425,16 +1426,17 @@ sysctl_procargs(name, namelen, where, sizep, up) * Now read the address of the argument vector. */ switch (type) { - case KERN_PROC_ARGV: + case KERN_PROC_ARGV: /* XXX compat32 stuff here */ - memcpy(&auio.uio_offset, (char *)&pss + p->p_psargv, - sizeof(auio.uio_offset)); + memcpy(&tmp, (char *)&pss + p->p_psargv, sizeof(tmp)); break; - case KERN_PROC_ENV: - memcpy(&auio.uio_offset, (char *)&pss + p->p_psenv, - sizeof(auio.uio_offset)); + case KERN_PROC_ENV: + memcpy(&tmp, (char *)&pss + p->p_psenv, sizeof(tmp)); break; + default: + return (EINVAL); } + auio.uio_offset = (off_t)(long)tmp; aiov.iov_base = &argv; aiov.iov_len = sizeof(argv); auio.uio_iov = &aiov;