CVE-2014-9653.2.445c8fb.patch 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. Subject: Bail out on partial reads, from Alexander Cherepanov (...)
  2. ID: CVE-2014-9653
  3. Upstream-Author: Christos Zoulas <christos@zoulas.com>
  4. Date: Tue Dec 16 20:53:05 2014 +0000
  5. Origin: FILE5_21-10-g445c8fb
  6. Last-Update: 2015-02-15
  7. Bail out on partial reads, from Alexander Cherepanov
  8. Note: Parts of that patch had already been cherry-picked as
  9. TEMP-0000000-B67840.11.445c8fb.patch
  10. --- a/src/readelf.c
  11. +++ b/src/readelf.c
  12. @@ -1014,7 +1014,7 @@
  13. }
  14. /* Read offset of name section to be able to read section names later */
  15. - if (pread(fd, xsh_addr, xsh_sizeof, off + size * strtab) == -1) {
  16. + if (pread(fd, xsh_addr, xsh_sizeof, off + size * strtab) < (ssize_t)xsh_sizeof) {
  17. file_badread(ms);
  18. return -1;
  19. }
  20. @@ -1022,11 +1022,11 @@
  21. for ( ; num; num--) {
  22. /* Read the name of this section. */
  23. - if (pread(fd, name, sizeof(name), name_off + xsh_name) == -1) {
  24. + if ((namesize = pread(fd, name, sizeof(name) - 1, name_off + xsh_name)) == -1) {
  25. file_badread(ms);
  26. return -1;
  27. }
  28. - name[sizeof(name) - 1] = '\0';
  29. + name[namesize] = '\0';
  30. if (strcmp(name, ".debug_info") == 0)
  31. stripped = 0;