Fix mmap failed(2) on 32-bit FreeBSD (bb #2300).

off_t is 64-bit, size_t is still 32-bit and that causes unexpected integer
promotion here:
map_off = map->len - 2048

First the unsigned subtraction is performed, and then the unsigned (!) value
is sign-extended to 64-bit. Hence a negative value becomes positive, which is
wrong.
0.96
Török Edvin 15 years ago
parent 9f021791d1
commit 8f6bf9fc08
  1. 4
      ChangeLog
  2. 2
      libclamav/pdf.c

@ -1,3 +1,7 @@
Tue Sep 28 12:42:01 EEST 2010 (edwin)
-------------------------------------
* libclamav/pdf.c: fix mmap failed(2) on 32-bit FreeBSD (bb #2300).
Thu Sep 23 17:59:26 CEST 2010 (acab)
------------------------------------
* m4/acinclude: add alarm(10) to the CVE-2010-0405 check so we don't

@ -1024,7 +1024,7 @@ int cli_pdf(const char *dir, cli_ctx *ctx, off_t offset)
offset += pdfver - start;
/* find trailer and xref, don't fail if not found */
map_off = map->len - 2048;
map_off = (off_t)map->len - 2048;
if (map_off < 0)
map_off = 0;
bytesleft = map->len - map_off;

Loading…
Cancel
Save