Skip to content

Commit

Permalink
Fix look(1) on x86_64.
Browse files Browse the repository at this point in the history
SIZE_T_MAX, being ULONG_MAX, was -1 when cast to off_t (int64_t).

Reported-by: Urmas Reinsalu <urki@klaasikoda.ee>
  • Loading branch information
Sascha Wildner committed Apr 8, 2010
1 parent 4d064aa commit 245af09
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion usr.bin/look/look.c
Expand Up @@ -134,7 +134,7 @@ main(int argc, char **argv)
do {
if ((fd = open(file, O_RDONLY, 0)) < 0 || fstat(fd, &sb))
err(2, "%s", file);
if (sb.st_size > (off_t)SIZE_T_MAX)
if ((size_t)sb.st_size > SIZE_T_MAX)
errx(2, "%s: %s", file, strerror(EFBIG));
if ((front = mmap(NULL, (size_t)sb.st_size, PROT_READ, MAP_SHARED, fd, (off_t)0)) == MAP_FAILED)
err(2, "%s", file);
Expand Down

0 comments on commit 245af09

Please sign in to comment.