cherry-pick.FILE5_34-32-g813f1b8a.correct-error-handling-for-file-printf-coverity.patch 826 B

12345678910111213141516171819202122232425262728
  1. Subject: Correct error handling for file_printf() (coverity)
  2. Origin: FILE5_34-32-g813f1b8a <https://github.com/file/file/commit/FILE5_34-32-g813f1b8a>
  3. Upstream-Author: Christos Zoulas <christos@zoulas.com>
  4. Date: Thu Aug 2 12:46:02 2018 +0000
  5. --- a/src/readelf.c
  6. +++ b/src/readelf.c
  7. @@ -1035,14 +1035,16 @@
  8. }
  9. if (namesz & 0x80000000) {
  10. - (void)file_printf(ms, ", bad note name size 0x%lx",
  11. - (unsigned long)namesz);
  12. + if (file_printf(ms, ", bad note name size 0x%lxx",
  13. + CAST(unsigned long, namesz)) == -1)
  14. + return -1;
  15. return 0;
  16. }
  17. if (descsz & 0x80000000) {
  18. - (void)file_printf(ms, ", bad note description size 0x%lx",
  19. - (unsigned long)descsz);
  20. + if (file_printf(ms, ", bad note description size 0x%lx",
  21. + CAST(unsigned long, descsz)) == -1)
  22. + return -1;
  23. return 0;
  24. }