Don't try to mmap the contents of empty files. This behaviour was harmless
prior to r195693, since historical behaviour of mmap(2) was to silently ignore length-zero mmap requests; but mmap now returns EINVAL, which caused look(1) to emit an error message and fail. Among other things, this makes `freebsd-update fetch` on a newly installed 8.0-BETA3 system print bogus warning messages. MFC after: 3 days
This commit is contained in:
parent
74d1c4927a
commit
f9f231846a
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user