summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>1998-04-18 19:24:44 +0000
committerdes <des@FreeBSD.org>1998-04-18 19:24:44 +0000
commit959a007c3a7c2927e121d62d1ea30160c4b452b9 (patch)
tree1415c1f6bce35d71db6d2f39a6a27fa7856afa33 /sys
parent231798aaaf9ad0bafd56df46d2f88928848206ef (diff)
downloadFreeBSD-src-959a007c3a7c2927e121d62d1ea30160c4b452b9.zip
FreeBSD-src-959a007c3a7c2927e121d62d1ea30160c4b452b9.tar.gz
Return EINVAL and do not change file pointer if resulting offset is negative.
PR: kern/6184
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_extattr.c12
-rw-r--r--sys/kern/vfs_syscalls.c12
2 files changed, 14 insertions, 10 deletions
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c
index 406bd37..1aacbb8 100644
--- a/sys/kern/vfs_extattr.c
+++ b/sys/kern/vfs_extattr.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
- * $Id: vfs_syscalls.c,v 1.96 1998/03/29 18:23:44 dyson Exp $
+ * $Id: vfs_syscalls.c,v 1.97 1998/04/08 18:31:57 wosch Exp $
*/
/* For 4.3 integer FS ID compatibility */
@@ -1324,6 +1324,7 @@ lseek(p, uap)
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
struct vattr vattr;
+ off_t ofs;
int error;
if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
@@ -1333,21 +1334,22 @@ lseek(p, uap)
return (ESPIPE);
switch (SCARG(uap, whence)) {
case L_INCR:
- fp->f_offset += SCARG(uap, offset);
+ ofs = fp->f_offset + SCARG(uap, offset);
break;
case L_XTND:
error=VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p);
if (error)
return (error);
- fp->f_offset = SCARG(uap, offset) + vattr.va_size;
+ ofs = SCARG(uap, offset) + vattr.va_size;
break;
case L_SET:
- fp->f_offset = SCARG(uap, offset);
+ ofs = SCARG(uap, offset);
break;
default:
return (EINVAL);
}
- *(off_t *)(p->p_retval) = fp->f_offset;
+ if (ofs < 0) return (EINVAL);
+ *(off_t *)(p->p_retval) = fp->f_offset = ofs;
return (0);
}
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 406bd37..1aacbb8 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
- * $Id: vfs_syscalls.c,v 1.96 1998/03/29 18:23:44 dyson Exp $
+ * $Id: vfs_syscalls.c,v 1.97 1998/04/08 18:31:57 wosch Exp $
*/
/* For 4.3 integer FS ID compatibility */
@@ -1324,6 +1324,7 @@ lseek(p, uap)
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
struct vattr vattr;
+ off_t ofs;
int error;
if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
@@ -1333,21 +1334,22 @@ lseek(p, uap)
return (ESPIPE);
switch (SCARG(uap, whence)) {
case L_INCR:
- fp->f_offset += SCARG(uap, offset);
+ ofs = fp->f_offset + SCARG(uap, offset);
break;
case L_XTND:
error=VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p);
if (error)
return (error);
- fp->f_offset = SCARG(uap, offset) + vattr.va_size;
+ ofs = SCARG(uap, offset) + vattr.va_size;
break;
case L_SET:
- fp->f_offset = SCARG(uap, offset);
+ ofs = SCARG(uap, offset);
break;
default:
return (EINVAL);
}
- *(off_t *)(p->p_retval) = fp->f_offset;
+ if (ofs < 0) return (EINVAL);
+ *(off_t *)(p->p_retval) = fp->f_offset = ofs;
return (0);
}
OpenPOWER on IntegriCloud