Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/netbsd32 fix the glaring errors in compat_13_netb...



details:   https://anonhg.NetBSD.org/src/rev/55c152454823
branches:  trunk
changeset: 503491:55c152454823
user:      mrg <mrg%NetBSD.org@localhost>
date:      Wed Feb 07 13:14:07 2001 +0000

description:
fix the glaring errors in compat_13_netbsd32_sigaltstack13

diffstat:

 sys/compat/netbsd32/netbsd32_compat_13.c |  54 ++++++++++++++++++++++---------
 1 files changed, 38 insertions(+), 16 deletions(-)

diffs (74 lines):

diff -r 60f4dee68eb4 -r 55c152454823 sys/compat/netbsd32/netbsd32_compat_13.c
--- a/sys/compat/netbsd32/netbsd32_compat_13.c  Wed Feb 07 13:13:01 2001 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_13.c  Wed Feb 07 13:14:07 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_compat_13.c,v 1.7 2000/07/09 13:39:31 mrg Exp $       */
+/*     $NetBSD: netbsd32_compat_13.c,v 1.8 2001/02/07 13:14:07 mrg Exp $       */
 
 /*
  * Copyright (c) 1998 Matthew R. Green
@@ -50,27 +50,49 @@
                syscallarg(netbsd32_sigaltstack13p_t) oss;
        } */ *uap = v;
        struct compat_13_sys_sigaltstack_args ua;
-       struct sigaltstack13 nss13, oss13;
-       struct netbsd32_sigaltstack13 *s32nss13, *s32oss13;
-       int rv;
+       struct sigaltstack13 ss13, *nss13up, *oss13up;
+       struct netbsd32_sigaltstack13 s32ss;
+       caddr_t sg;
+       int error;
+
+       if (!SCARG(uap, nss))
+               return (EINVAL);
 
-       SCARG(&ua, nss) = &nss13;
-       SCARG(&ua, oss) = &oss13;
+       sg = stackgap_init(p->p_emul);
 
-       s32nss13 = (struct netbsd32_sigaltstack13 *)(u_long)SCARG(uap, nss);
-       s32oss13 = (struct netbsd32_sigaltstack13 *)(u_long)SCARG(uap, oss);
+       SCARG(&ua, nss) = nss13up = stackgap_alloc(&sg, sizeof(*nss13up));
+       if (SCARG(uap, oss))
+               SCARG(&ua, oss) = oss13up = stackgap_alloc(&sg, sizeof(*oss13up));
+       else
+               SCARG(&ua, oss) = NULL;
 
-       nss13.ss_sp = (char *)(u_long)s32nss13->ss_sp;
-       nss13.ss_size = s32nss13->ss_size;
-       nss13.ss_flags = s32nss13->ss_flags;
+       error = copyin((caddr_t)(u_long)SCARG(uap, nss), &s32ss, sizeof s32ss);
+       if (error)
+               return (error);
+       ss13.ss_sp = (char *)(u_long)s32ss.ss_sp;
+       ss13.ss_size = s32ss.ss_size;
+       ss13.ss_flags = s32ss.ss_flags;
+       error = copyout(&ss13, nss13up, sizeof *nss13up);
+       if (error)
+               return (error);
 
-       rv = compat_13_sys_sigaltstack(p, &ua, retval);
+       error = compat_13_sys_sigaltstack(p, &ua, retval);
+       if (error)
+               return (error);
 
-       s32oss13->ss_sp = (netbsd32_charp)(u_long)oss13.ss_sp;
-       s32oss13->ss_size = oss13.ss_size;
-       s32oss13->ss_flags = oss13.ss_flags;
+       if (SCARG(uap, oss)) {
+               error = copyin(nss13up, &ss13, sizeof *nss13up);
+               if (error)
+                       return (error);
+               s32ss.ss_sp = (netbsd32_charp)(u_long)ss13.ss_sp;
+               s32ss.ss_size = ss13.ss_size;
+               s32ss.ss_flags = ss13.ss_flags;
+               error = copyout(&s32ss, (caddr_t)(u_long)SCARG(uap, nss), sizeof s32ss);
+               if (error)
+                       return (error);
+       }
 
-       return (rv);
+       return (0);
 }
 
 



Home | Main Index | Thread Index | Old Index