git_fixes.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. diff -aur file-5.18/ChangeLog file.git/ChangeLog
  2. --- file-5.18/ChangeLog 2014-03-26 16:27:39.000000000 +0100
  3. +++ file.git/ChangeLog 2014-04-03 18:50:06.066659023 +0200
  4. @@ -1,3 +1,7 @@
  5. +2014-04-01 15:25 Christos Zoulas <christos@zoulas.com>
  6. +
  7. + * PR/341: Jan Kaluza, fix memory leak
  8. + * PR/342: Jan Kaluza, fix out of bounds read
  9. 2014-03-26 11:25 Christos Zoulas <christos@zoulas.com>
  10. * release 5.18
  11. diff -aur file-5.18/src/apprentice.c file.git/src/apprentice.c
  12. --- file-5.18/src/apprentice.c 2014-03-14 19:48:11.000000000 +0100
  13. +++ file.git/src/apprentice.c 2014-04-03 18:50:06.086659024 +0200
  14. @@ -517,14 +517,18 @@
  15. {
  16. if (map == NULL)
  17. return;
  18. - if (map->p == NULL)
  19. - return;
  20. + if (map->p != NULL) {
  21. #ifdef QUICK
  22. - if (map->len)
  23. - (void)munmap(map->p, map->len);
  24. - else
  25. + if (map->len)
  26. + (void)munmap(map->p, map->len);
  27. + else
  28. #endif
  29. free(map->p);
  30. + } else {
  31. + uint32_t j;
  32. + for (j = 0; j < MAGIC_SETS; j++)
  33. + free(map->magic[j]);
  34. + }
  35. free(map);
  36. }
  37. @@ -1290,11 +1294,7 @@
  38. magic_entry_free(mset[j].me, mset[j].count);
  39. if (errs) {
  40. - for (j = 0; j < MAGIC_SETS; j++) {
  41. - if (map->magic[j])
  42. - free(map->magic[j]);
  43. - }
  44. - free(map);
  45. + apprentice_unmap(map);
  46. return NULL;
  47. }
  48. return map;
  49. diff -aur file-5.18/python/magic.py file.git/python/magic.py
  50. --- file-5.18/python/magic.py 2014-04-04 20:34:38.086623965 +0200
  51. +++ file.git/python/magic.py 2014-04-04 20:35:42.886623752 +0200
  52. @@ -116,7 +116,10 @@
  53. is set. A call to errno() will return the numeric error code.
  54. """
  55. try: # attempt python3 approach first
  56. - bi = bytes(filename, 'utf-8')
  57. + if isinstance(filename, bytes):
  58. + bi = filename
  59. + else:
  60. + bi = bytes(filename, 'utf-8')
  61. return str(_file(self._magic_t, bi), 'utf-8')
  62. except:
  63. return _file(self._magic_t, filename.encode('utf-8'))