summaryrefslogtreecommitdiffstats
path: root/usr.bin/look/look.c
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2011-10-16 19:15:25 +0000
committered <ed@FreeBSD.org>2011-10-16 19:15:25 +0000
commit191c732ed60c9200ff526deeeab3d4118a498e7e (patch)
treea42dda20a72d9ca17ea36149e7254129e0761fdc /usr.bin/look/look.c
parent3b0e8ca514f0684a2792360344152f202567cffb (diff)
downloadFreeBSD-src-191c732ed60c9200ff526deeeab3d4118a498e7e.zip
FreeBSD-src-191c732ed60c9200ff526deeeab3d4118a498e7e.tar.gz
Don't cast SIZE_T_MAX to off_t.
I focused so much on the 32-bits case where we have to cast SIZE_T_MAX up in size, that I forgot about the 64-bits case, where off_t and size_t are equal in size. Simply cast both numbers to uintmax_t, as we can assume st_size is never negative. Reported by: cperciva
Diffstat (limited to 'usr.bin/look/look.c')
-rw-r--r--usr.bin/look/look.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/usr.bin/look/look.c b/usr.bin/look/look.c
index ac6082e..0088864 100644
--- a/usr.bin/look/look.c
+++ b/usr.bin/look/look.c
@@ -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 ((uintmax_t)sb.st_size > (uintmax_t)SIZE_T_MAX)
errx(2, "%s: %s", file, strerror(EFBIG));
if (sb.st_size == 0) {
close(fd);
OpenPOWER on IntegriCloud