Source-Changes-HG archive

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

[src/trunk]: src Follow OpenGroup online documents for truncate[1] and ftrunc...



details:   https://anonhg.NetBSD.org/src/rev/5667c5f32ac4
branches:  trunk
changeset: 329932:5667c5f32ac4
user:      njoly <njoly%NetBSD.org@localhost>
date:      Sat Jun 14 11:37:35 2014 +0000

description:
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

diffstat:

 lib/libc/sys/truncate.2 |   8 ++++++--
 sys/kern/vfs_syscalls.c |  10 ++++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diffs (67 lines):

diff -r e3c3d45e3cfd -r 5667c5f32ac4 lib/libc/sys/truncate.2
--- a/lib/libc/sys/truncate.2   Sat Jun 14 09:13:30 2014 +0000
+++ b/lib/libc/sys/truncate.2   Sat Jun 14 11:37:35 2014 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: truncate.2,v 1.26 2010/05/31 12:16:20 njoly Exp $
+.\"    $NetBSD: truncate.2,v 1.27 2014/06/14 11:37:35 njoly 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 @@
 .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
diff -r e3c3d45e3cfd -r 5667c5f32ac4 sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c   Sat Jun 14 09:13:30 2014 +0000
+++ b/sys/kern/vfs_syscalls.c   Sat Jun 14 11:37:35 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls.c,v 1.483 2014/06/12 21:39:45 joerg Exp $ */
+/*     $NetBSD: vfs_syscalls.c,v 1.484 2014/06/14 11:37:35 njoly 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.483 2014/06/12 21:39:45 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.484 2014/06/14 11:37:35 njoly Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_fileassoc.h"
@@ -3923,6 +3923,9 @@
        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)
@@ -3957,6 +3960,9 @@
        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);



Home | Main Index | Thread Index | Old Index