In mmap(), bail out with EOVERFLOW when mapping a regular file and the file
offset plus mapping length cannot be represented in an off_t.
This commit is contained in:
parent
2e68f6172e
commit
7e35a43e67
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: mmap.2,v 1.20 1999/12/02 21:42:38 kleink Exp $
|
||||
.\" $NetBSD: mmap.2,v 1.21 2000/03/28 18:45:19 kleink Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -232,6 +232,13 @@ was specified and the
|
|||
parameter wasn't available.
|
||||
.Dv MAP_ANON
|
||||
was specified and insufficient memory was available.
|
||||
.It Bq Er EOVERFLOW
|
||||
.Fa fd
|
||||
references a regular file and the value of
|
||||
.Fa offset
|
||||
plus
|
||||
.Fa len
|
||||
would exceed the offset maximum established in its open file description.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr madvise 2 ,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: uvm_mmap.c,v 1.38 2000/03/26 20:54:47 kleink Exp $ */
|
||||
/* $NetBSD: uvm_mmap.c,v 1.39 2000/03/28 18:45:20 kleink Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Charles D. Cranor and Washington University.
|
||||
|
@ -404,6 +404,9 @@ sys_mmap(p, v, retval)
|
|||
vp->v_type != VBLK)
|
||||
return (ENODEV); /* only REG/CHR/BLK support mmap */
|
||||
|
||||
if (vp->v_type == VREG && (pos + size) < pos)
|
||||
return (EOVERFLOW); /* no offset wrapping */
|
||||
|
||||
/* special case: catch SunOS style /dev/zero */
|
||||
if (vp->v_type == VCHR && iszerodev(vp->v_rdev)) {
|
||||
flags |= MAP_ANON;
|
||||
|
|
Loading…
Reference in New Issue