summaryrefslogtreecommitdiffstats
path: root/usr.bin/file/file.c
diff options
context:
space:
mode:
authortobias <tobias@openbsd.org>2015-07-08 17:49:45 +0000
committertobias <tobias@openbsd.org>2015-07-08 17:49:45 +0000
commit90600e8ab3e50b7f44fb340786e031497aabba4a (patch)
treea2b30d6395aff7280172851a1da44a645368e447 /usr.bin/file/file.c
parentDo not allow '\0' as an offset operator or type. (diff)
downloadwireguard-openbsd-90600e8ab3e50b7f44fb340786e031497aabba4a.tar.xz
wireguard-openbsd-90600e8ab3e50b7f44fb340786e031497aabba4a.zip
Properly handle files >= 4 GB on 32 bit architectures.
with input by and ok nicm@
Diffstat (limited to 'usr.bin/file/file.c')
-rw-r--r--usr.bin/file/file.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/file/file.c b/usr.bin/file/file.c
index ba0c3df0903..7de5614484c 100644
--- a/usr.bin/file/file.c
+++ b/usr.bin/file/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.45 2015/05/30 06:25:35 nicm Exp $ */
+/* $OpenBSD: file.c,v 1.46 2015/07/08 17:49:45 tobias Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -413,11 +413,12 @@ load_file(struct input_file *inf)
{
size_t used;
- inf->size = inf->msg->sb.st_size;
- if (inf->size == 0 && S_ISREG(inf->msg->sb.st_mode))
+ if (inf->msg->sb.st_size == 0 && S_ISREG(inf->msg->sb.st_mode))
return (0); /* empty file */
- if (inf->size == 0 || inf->size > FILE_READ_SIZE)
+ if (inf->msg->sb.st_size == 0 || inf->msg->sb.st_size > FILE_READ_SIZE)
inf->size = FILE_READ_SIZE;
+ else
+ inf->size = inf->msg->sb.st_size;
if (!S_ISREG(inf->msg->sb.st_mode))
goto try_read;