Date: Mon, 31 Aug 2009 13:02:21 +0000 (UTC) From: Colin Percival <cperciva@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r196695 - stable/8/usr.bin/look Message-ID: <200908311302.n7VD2Lg8028259@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: cperciva Date: Mon Aug 31 13:02:21 2009 New Revision: 196695 URL: http://svn.freebsd.org/changeset/base/196695 Log: MFC r196558: Don't try to mmap the contents of empty files. This behaviour was harmless prior to r195693, when mmap(2) changed from silently ignoring requests for mapping zero bytes to returning EINVAL; this commit can be seen as adjusting for the change in mmap(2) in order to make look(1) act like it did previously. Reviewed by: jhb Approved by: re (kib) Modified: stable/8/usr.bin/look/ (props changed) stable/8/usr.bin/look/look.c Modified: stable/8/usr.bin/look/look.c ============================================================================== --- stable/8/usr.bin/look/look.c Mon Aug 31 12:25:04 2009 (r196694) +++ stable/8/usr.bin/look/look.c Mon Aug 31 13:02:21 2009 (r196695) @@ -140,6 +140,10 @@ main(int argc, char *argv[]) err(2, "%s", file); if (sb.st_size > SIZE_T_MAX) errx(2, "%s: %s", file, strerror(EFBIG)); + if (sb.st_size == 0) { + close(fd); + continue; + } if ((front = mmap(NULL, (size_t)sb.st_size, PROT_READ, MAP_SHARED, fd, (off_t)0)) == MAP_FAILED) err(2, "%s", file); back = front + sb.st_size;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908311302.n7VD2Lg8028259>