cherry-pick.FILE5_35-31-g2858eaf9.avoid-oob-read-found-by-asan-reported-by-f.patch 666 B

123456789101112131415161718
  1. Subject: Avoid OOB read (found by ASAN reported by F. Alonso)
  2. ID: CVE-2019-8906
  3. Origin: FILE5_35-31-g2858eaf9 <https://github.com/file/file/commit/FILE5_35-31-g2858eaf9>
  4. Upstream-Author: Christos Zoulas <christos@zoulas.com>
  5. Date: Wed Jan 2 19:44:14 2019 +0000
  6. Bug-Debian: https://bugs.debian.org/922969
  7. --- a/src/readelf.c
  8. +++ b/src/readelf.c
  9. @@ -752,7 +752,7 @@
  10. char sbuf[512];
  11. struct NetBSD_elfcore_procinfo pi;
  12. memset(&pi, 0, sizeof(pi));
  13. - memcpy(&pi, nbuf + doff, descsz);
  14. + memcpy(&pi, nbuf + doff, MIN(descsz, sizeof(pi)));
  15. if (file_printf(ms, ", from '%.31s', pid=%u, uid=%u, "
  16. "gid=%u, nlwps=%u, lwp=%u (signal %u/code %u)",