From 9a0b176050d4abe3bec00aa646570b9aa4c930de Mon Sep 17 00:00:00 2001 From: christos Date: Sat, 22 May 2004 20:46:53 +0000 Subject: [PATCH] allocate memory for statvfs instead of using the stack. --- sys/compat/common/vfs_syscalls_20.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/sys/compat/common/vfs_syscalls_20.c b/sys/compat/common/vfs_syscalls_20.c index 6d2db82f3686..f79de73117dc 100644 --- a/sys/compat/common/vfs_syscalls_20.c +++ b/sys/compat/common/vfs_syscalls_20.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_syscalls_20.c,v 1.1 2004/04/21 01:05:36 christos Exp $ */ +/* $NetBSD: vfs_syscalls_20.c,v 1.2 2004/05/22 20:46:53 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_20.c,v 1.1 2004/04/21 01:05:36 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_20.c,v 1.2 2004/05/22 20:46:53 christos Exp $"); #include "opt_compat_netbsd.h" #include "opt_compat_43.h" @@ -150,18 +150,25 @@ compat_20_sys_statfs(l, v, retval) } */ *uap = v; struct proc *p = l->l_proc; struct mount *mp; - struct statvfs sbuf; - int error; + struct statvfs *sbuf; + int error = 0; struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); if ((error = namei(&nd)) != 0) return error; + mp = nd.ni_vp->v_mount; vrele(nd.ni_vp); + + sbuf = malloc(sizeof(*sbuf), M_TEMP, M_WAITOK); if ((error = dostatvfs(mp, &sbuf, p, 0, 1)) != 0) - return error; - return vfs2fs(SCARG(uap, buf), &sbuf); + goto done; + + error = vfs2fs(SCARG(uap, buf), &sbuf); +done: + free(sbuf, M_TEMP); + return error; } /*