cherry-pick.FILE5_35-1-g338cc788.-c-cast.patch 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. Subject: - C++ cast (...)
  2. Origin: FILE5_35-1-g338cc788 <https://github.com/file/file/commit/FILE5_35-1-g338cc788>
  3. Upstream-Author: Christos Zoulas <christos@zoulas.com>
  4. Date: Fri Oct 19 00:26:08 2018 +0000
  5. - C++ cast
  6. - return 0 instead of -1 for error in donote
  7. --- a/src/readelf.c
  8. +++ b/src/readelf.c
  9. @@ -786,8 +786,8 @@
  10. pidoff = argoff + 81 + 2;
  11. if (doff + pidoff + 4 <= size) {
  12. if (file_printf(ms, ", pid=%u",
  13. - elf_getu32(swap, *(uint32_t *)(nbuf +
  14. - doff + pidoff))) == -1)
  15. + elf_getu32(swap, *RCAST(uint32 *, (nbuf +
  16. + doff + pidoff)))) == -1)
  17. return 1;
  18. }
  19. *flags |= FLAGS_DID_CORE;
  20. @@ -1142,14 +1142,14 @@
  21. if (namesz & 0x80000000) {
  22. if (file_printf(ms, ", bad note name size %#lx",
  23. CAST(unsigned long, namesz)) == -1)
  24. - return -1;
  25. + return 0;
  26. return 0;
  27. }
  28. if (descsz & 0x80000000) {
  29. if (file_printf(ms, ", bad note description size %#lx",
  30. CAST(unsigned long, descsz)) == -1)
  31. - return -1;
  32. + return 0;
  33. return 0;
  34. }
  35. @@ -1668,7 +1668,7 @@
  36. case PT_INTERP:
  37. if (bufsize && nbuf[0]) {
  38. nbuf[bufsize - 1] = '\0';
  39. - memcpy(interp, nbuf, bufsize);
  40. + memcpy(interp, nbuf, (size_t)bufsize);
  41. } else
  42. strlcpy(interp, "*empty*", sizeof(interp));
  43. break;