0001-Avoid-reading-past-the-end-of-buffer-Rui-Reis.patch 947 B

123456789101112131415161718192021222324252627282930
  1. From a642587a9c9e2dd7feacdf513c3643ce26ad3c22 Mon Sep 17 00:00:00 2001
  2. From: Christos Zoulas <christos@zoulas.com>
  3. Date: Sat, 9 Jun 2018 16:00:06 +0000
  4. Subject: [PATCH] Avoid reading past the end of buffer (Rui Reis)
  5. [baruch: drop file version string update hunk]
  6. Signed-off-by: Baruch Siach <baruch@tkos.co.il>
  7. ---
  8. Upstream status: commit a642587a9c9 in github mirror
  9. src/readelf.c | 5 +++--
  10. 1 file changed, 3 insertions(+), 2 deletions(-)
  11. diff --git a/src/readelf.c b/src/readelf.c
  12. index 79c83f9f5048..1f41b46113c3 100644
  13. --- a/src/readelf.c
  14. +++ b/src/readelf.c
  15. @@ -842,7 +842,8 @@ do_core_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
  16. cname = (unsigned char *)
  17. &nbuf[doff + prpsoffsets(i)];
  18. - for (cp = cname; *cp && isprint(*cp); cp++)
  19. + for (cp = cname; cp < nbuf + size && *cp
  20. + && isprint(*cp); cp++)
  21. continue;
  22. /*
  23. * Linux apparently appends a space at the end
  24. --
  25. 2.17.1