cherry-pick.FILE5_36-24-g9b2f9d6a.cast-to-unsigned-first-to-appease-ubsan-oss-fuzz.patch 696 B

123456789101112131415161718192021
  1. Subject: Cast to unsigned first to appease ubsan (oss-fuzz)
  2. Origin: FILE5_36-24-g9b2f9d6a <https://github.com/file/file/commit/FILE5_36-24-g9b2f9d6a>
  3. Upstream-Author: Christos Zoulas <christos@zoulas.com>
  4. Date: Sat Feb 23 21:54:05 2019 +0000
  5. --- a/src/encoding.c
  6. +++ b/src/encoding.c
  7. @@ -481,11 +481,11 @@
  8. if (bigend)
  9. ubf[(*ulen)++] = bf[i + 3] | (bf[i + 2] << 8)
  10. | (bf[i + 1] << 16)
  11. - | CAST(unichar, bf[i] << 24);
  12. + | (CAST(unichar, bf[i]) << 24);
  13. else
  14. ubf[(*ulen)++] = bf[i] | (bf[i + 1] << 8)
  15. | (bf[i + 2] << 16)
  16. - | CAST(unichar, bf[i + 3] << 24);
  17. + | (CAST(unichar, bf[i + 3]) << 24);
  18. if (ubf[*ulen - 1] == 0xfffe)
  19. return 0;