libquicktime-1.2.4-CVE-2017-9122_et_al.patch 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. From: Burkhard Plaum <plaum@ipf.uni-stuttgart.de>
  2. Origin: https://sourceforge.net/p/libquicktime/mailman/libquicktime-devel/?viewmonth=201706
  3. Hi,
  4. I committed some (mostly trivial) updates to CVS. The following CVE's
  5. are fixed and/or no longer reproducible:
  6. CVE-2017-9122
  7. CVE-2017-9123
  8. CVE-2017-9124
  9. CVE-2017-9125
  10. CVE-2017-9126
  11. CVE-2017-9127
  12. CVE-2017-9128
  13. I was a bit surprised that one simple sanity check fixes a whole bunch of files.
  14. So it could be, that the problems are still there, but better hidden since the
  15. critical code isn't executed anymore with the sample files I got.
  16. If someone encounters more crashes, feel free to report them.
  17. Burkhard
  18. --- a/include/lqt_funcprotos.h
  19. +++ b/include/lqt_funcprotos.h
  20. @@ -1345,9 +1345,9 @@ int quicktime_write_int32_le(quicktime_t
  21. int quicktime_write_char32(quicktime_t *file, char *string);
  22. float quicktime_read_fixed16(quicktime_t *file);
  23. int quicktime_write_fixed16(quicktime_t *file, float number);
  24. -unsigned long quicktime_read_uint32(quicktime_t *file);
  25. -long quicktime_read_int32(quicktime_t *file);
  26. -long quicktime_read_int32_le(quicktime_t *file);
  27. +uint32_t quicktime_read_uint32(quicktime_t *file);
  28. +int32_t quicktime_read_int32(quicktime_t *file);
  29. +int32_t quicktime_read_int32_le(quicktime_t *file);
  30. int64_t quicktime_read_int64(quicktime_t *file);
  31. int64_t quicktime_read_int64_le(quicktime_t *file);
  32. long quicktime_read_int24(quicktime_t *file);
  33. --- a/src/atom.c
  34. +++ b/src/atom.c
  35. @@ -131,6 +131,9 @@ int quicktime_atom_read_header(quicktime
  36. atom->size = read_size64(header);
  37. atom->end = atom->start + atom->size;
  38. }
  39. +/* Avoid broken files */
  40. + if(atom->end > file->total_length)
  41. + result = 1;
  42. }
  43. --- a/src/lqt_quicktime.c
  44. +++ b/src/lqt_quicktime.c
  45. @@ -1788,8 +1788,8 @@ int quicktime_read_info(quicktime_t *fil
  46. quicktime_set_position(file, start_position);
  47. free(temp);
  48. - quicktime_read_moov(file, &file->moov, &leaf_atom);
  49. - got_header = 1;
  50. + if(!quicktime_read_moov(file, &file->moov, &leaf_atom))
  51. + got_header = 1;
  52. }
  53. else
  54. quicktime_atom_skip(file, &leaf_atom);
  55. --- a/src/moov.c
  56. +++ b/src/moov.c
  57. @@ -218,7 +218,8 @@ int quicktime_read_moov(quicktime_t *fil
  58. if(quicktime_atom_is(&leaf_atom, "trak"))
  59. {
  60. quicktime_trak_t *trak = quicktime_add_trak(file);
  61. - quicktime_read_trak(file, trak, &leaf_atom);
  62. + if(quicktime_read_trak(file, trak, &leaf_atom))
  63. + return 1;
  64. }
  65. else
  66. if(quicktime_atom_is(&leaf_atom, "udta"))
  67. --- a/src/trak.c
  68. +++ b/src/trak.c
  69. @@ -269,6 +269,14 @@ int quicktime_read_trak(quicktime_t *fil
  70. else quicktime_atom_skip(file, &leaf_atom);
  71. } while(quicktime_position(file) < trak_atom->end);
  72. + /* Do some sanity checks to prevent later crashes */
  73. + if(trak->mdia.minf.is_video || trak->mdia.minf.is_video)
  74. + {
  75. + if(!trak->mdia.minf.stbl.stsc.table ||
  76. + !trak->mdia.minf.stbl.stco.table)
  77. + return 1;
  78. + }
  79. +
  80. #if 1
  81. if(trak->mdia.minf.is_video &&
  82. quicktime_match_32(trak->mdia.minf.stbl.stsd.table[0].format, "drac"))
  83. --- a/src/util.c
  84. +++ b/src/util.c
  85. @@ -647,10 +647,10 @@ int quicktime_write_fixed16(quicktime_t
  86. return quicktime_write_data(file, data, 2);
  87. }
  88. -unsigned long quicktime_read_uint32(quicktime_t *file)
  89. +uint32_t quicktime_read_uint32(quicktime_t *file)
  90. {
  91. - unsigned long result;
  92. - unsigned long a, b, c, d;
  93. + uint32_t result;
  94. + uint32_t a, b, c, d;
  95. uint8_t data[4];
  96. quicktime_read_data(file, data, 4);
  97. @@ -663,10 +663,10 @@ unsigned long quicktime_read_uint32(quic
  98. return result;
  99. }
  100. -long quicktime_read_int32(quicktime_t *file)
  101. +int32_t quicktime_read_int32(quicktime_t *file)
  102. {
  103. - unsigned long result;
  104. - unsigned long a, b, c, d;
  105. + uint32_t result;
  106. + uint32_t a, b, c, d;
  107. uint8_t data[4];
  108. quicktime_read_data(file, data, 4);
  109. @@ -676,13 +676,13 @@ long quicktime_read_int32(quicktime_t *f
  110. d = data[3];
  111. result = (a << 24) | (b << 16) | (c << 8) | d;
  112. - return (long)result;
  113. + return (int32_t)result;
  114. }
  115. -long quicktime_read_int32_le(quicktime_t *file)
  116. +int32_t quicktime_read_int32_le(quicktime_t *file)
  117. {
  118. - unsigned long result;
  119. - unsigned long a, b, c, d;
  120. + uint32_t result;
  121. + uint32_t a, b, c, d;
  122. uint8_t data[4];
  123. quicktime_read_data(file, data, 4);
  124. @@ -692,7 +692,7 @@ long quicktime_read_int32_le(quicktime_t
  125. d = data[3];
  126. result = (d << 24) | (c << 16) | (b << 8) | a;
  127. - return (long)result;
  128. + return (int32_t)result;
  129. }
  130. int64_t quicktime_read_int64(quicktime_t *file)