Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/tail fix tail; don't try to map more of the file tha...



details:   https://anonhg.NetBSD.org/src/rev/703bf9f2cced
branches:  trunk
changeset: 518084:703bf9f2cced
user:      explorer <explorer%NetBSD.org@localhost>
date:      Sat Nov 24 02:30:17 2001 +0000

description:
fix tail; don't try to map more of the file than really exists

diffstat:

 usr.bin/tail/forward.c |  13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diffs (43 lines):

diff -r 4206d25b31ae -r 703bf9f2cced usr.bin/tail/forward.c
--- a/usr.bin/tail/forward.c    Sat Nov 24 02:09:11 2001 +0000
+++ b/usr.bin/tail/forward.c    Sat Nov 24 02:30:17 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: forward.c,v 1.17 2001/11/21 06:47:07 explorer Exp $    */
+/*     $NetBSD: forward.c,v 1.18 2001/11/24 02:30:17 explorer Exp $    */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)forward.c  8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: forward.c,v 1.17 2001/11/21 06:47:07 explorer Exp $");
+__RCSID("$NetBSD: forward.c,v 1.18 2001/11/24 02:30:17 explorer Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -263,11 +263,11 @@
                return (0);
        file_remaining = file_size;
 
-       if (mmap_size > MMAP_MAXSIZE) {
+       if (file_remaining > MMAP_MAXSIZE) {
                mmap_size = MMAP_MAXSIZE;
-               mmap_offset = file_size - MMAP_MAXSIZE;
+               mmap_offset = file_remaining - MMAP_MAXSIZE;
        } else {
-               mmap_size = file_size;
+               mmap_size = file_remaining;
                mmap_offset = 0;
        }
 
@@ -292,6 +292,9 @@
                if (off == 0)
                        break;
 
+               if (file_remaining == 0)
+                       break;
+
                if (munmap(start, mmap_size)) {
                        err(0, "%s: %s", fname, strerror(errno));
                        return (1);



Home | Main Index | Thread Index | Old Index