32 bit systems might encounter a file which is larger than 2 GB. The
current code would silently truncate the input.
Exit with a proper error message instead.
Add the equal check to silence compiler warnings on 64 bit systems.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
err(EXIT_FAILURE, _("cannot open %s"), ctl->filename);
if (fstat(fd, &st))
err(EXIT_FAILURE, _("stat of %s failed"), ctl->filename);
+ if ((intmax_t)st.st_size >= (intmax_t)SINT_MAX(ssize_t))
+ err(EXIT_FAILURE, _("%s is too large"), ctl->filename);
*buf = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (*buf == MAP_FAILED)