Module Name: src
Committed By: msaitoh
Date: Mon Nov 3 19:48:14 UTC 2014
Modified Files:
src/lib/libc/sys [netbsd-6]: truncate.2
src/sys/kern [netbsd-6]: vfs_syscalls.c
Log Message:
Pull up following revision(s) (requested by manu in ticket #1150):
lib/libc/sys/truncate.2: revision 1.27
sys/kern/vfs_syscalls.c: revision 1.484
Follow OpenGroup online documents for truncate[1] and ftruncate[2].
Fail with EINVAL for length argument negative values.
[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html
[2] http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html
To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.26.8.1 src/lib/libc/sys/truncate.2
cvs rdiff -u -r1.449.2.3 -r1.449.2.4 src/sys/kern/vfs_syscalls.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/sys/truncate.2
diff -u src/lib/libc/sys/truncate.2:1.26 src/lib/libc/sys/truncate.2:1.26.8.1
--- src/lib/libc/sys/truncate.2:1.26 Mon May 31 12:16:20 2010
+++ src/lib/libc/sys/truncate.2 Mon Nov 3 19:48:14 2014
@@ -1,4 +1,4 @@
-.\" $NetBSD: truncate.2,v 1.26 2010/05/31 12:16:20 njoly Exp $
+.\" $NetBSD: truncate.2,v 1.26.8.1 2014/11/03 19:48:14 msaitoh Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" @(#)truncate.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd March 16, 2008
+.Dd June 14, 2014
.Dt TRUNCATE 2
.Os
.Sh NAME
@@ -76,6 +76,10 @@ and
.Fn ftruncate
are:
.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa length
+argument was less than 0.
.It Bq Er EISDIR
The named file is a directory.
.It Bq Er EROFS
Index: src/sys/kern/vfs_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.449.2.3 src/sys/kern/vfs_syscalls.c:1.449.2.4
--- src/sys/kern/vfs_syscalls.c:1.449.2.3 Mon Apr 21 10:14:17 2014
+++ src/sys/kern/vfs_syscalls.c Mon Nov 3 19:48:14 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_syscalls.c,v 1.449.2.3 2014/04/21 10:14:17 bouyer Exp $ */
+/* $NetBSD: vfs_syscalls.c,v 1.449.2.4 2014/11/03 19:48:14 msaitoh Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.449.2.3 2014/04/21 10:14:17 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.449.2.4 2014/11/03 19:48:14 msaitoh Exp $");
#ifdef _KERNEL_OPT
#include "opt_fileassoc.h"
@@ -3637,6 +3637,9 @@ sys_truncate(struct lwp *l, const struct
struct vattr vattr;
int error;
+ if (SCARG(uap, length) < 0)
+ return EINVAL;
+
error = namei_simple_user(SCARG(uap, path),
NSM_FOLLOW_TRYEMULROOT, &vp);
if (error != 0)
@@ -3671,6 +3674,9 @@ sys_ftruncate(struct lwp *l, const struc
file_t *fp;
int error;
+ if (SCARG(uap, length) < 0)
+ return EINVAL;
+
/* fd_getvnode() will use the descriptor for us */
if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);