Skip to content
Myr

Fix seven bugs discovered and fixed by ForAllSecure:

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sean Barrett · committed by Sean Barrett · parent c72a95d · Browse files · 1 file+22 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • CVE-2019-13217: heap buffer overflow in start_decoder()
  • CVE-2019-13218: stack buffer overflow in compute_codewords()
  • CVE-2019-13219: uninitialized memory in vorbis_decode_packet_rest()
  • CVE-2019-13220: out-of-range read in draw_line()
  • CVE-2019-13221: issue with large 1D codebooks in lookup1_values()
  • CVE-2019-13222: unchecked NULL returned by get_window()
  • CVE-2019-13223: division by zero in predict_point()

Diff stats

1 file+22 added−6 removed

  • other:+22 added−6 removed

1 file+22 added−6 removed

modified:stb_vorbis.c+22 added-6 removed
31 unmodified lines
32// manxorist@github saga musix github:infatum33// Timur Gagiev34//35// Partial history:36// 1.17 - 2019-07-08 - fix CVE-2019-13217..CVE-2019-13223 (by ForAllSecure)37// 1.16 - 2019-03-04 - fix warnings38// 1.15 - 2019-02-07 - explicit failure if Ogg Skeleton data is found39// 1.14 - 2018-02-11 - delete bogus dealloca usage40// 1.13 - 2018-01-29 - fix truncation of last frame (hopefully)
1161 unmodified lines
1202{1203 int r = (int) floor(exp((float) log((float) entries) / dim));1204 if ((int) floor(pow((float) r+1, dim)) <= entries) // (int) cast for MinGW warning;1205 ++r; // floor() to avoid _ftol() when non-CRT1205 assert(pow((float) r+1, dim) > entries);1206 assert((int) floor(pow((float) r, dim)) <= entries); // (int),floor() as above1206 if (pow((float) r+1, dim) <= entries)1207 return -1;1208 if ((int) floor(pow((float) r, dim)) > entries)1209 return -1;1210 return r;1211}12121213// called twice per file
801 unmodified lines
2015#endif2016 ady -= abs(base) * adx;2017 if (x1 > n) x1 = n;2018 if (x < x1) {2016 LINE_OP(output[x], inverse_db_table[y]);2019 LINE_OP(output[x], inverse_db_table[y&255]);2020 for (++x; x < x1; ++x) {2021 err += ady;2022 if (err >= adx) {2023 err -= adx;2024 y += sy;2025 } else2026 y += base;2024 LINE_OP(output[x], inverse_db_table[y]);2027 LINE_OP(output[x], inverse_db_table[y&255]);2028 }2029 }2030}2031
1018 unmodified lines
3050{3051 len <<= 1;3052 if (len == f->blocksize_0) return f->window[0];3053 if (len == f->blocksize_1) return f->window[1];3051 assert(0);3054 return NULL;3055}30563057#ifndef STB_VORBIS_NO_DEFER_FLOOR
397 unmodified lines
3455 // mixin from previous window3456 if (f->previous_length) {3457 int i,j, n = f->previous_length;3458 float *w = get_window(f, n);3459 if (w == NULL) return 0;3460 for (i=0; i < f->channels; ++i) {3461 for (j=0; j < n; ++j)3462 f->channel_buffers[i][left+j] =3463 f->channel_buffers[i][left+j]*w[ j] +
233 unmodified lines
3697 int current_length = get_bits(f,5) + 1;3698 while (current_entry < c->entries) {3699 int limit = c->entries - current_entry;3700 int n = get_bits(f, ilog(limit));3701 if (current_length >= 32) return error(f, VORBIS_invalid_setup);3702 if (current_entry + n > (int) c->entries) { return error(f, VORBIS_invalid_setup); }3703 memset(lengths + current_entry, current_length, n);3704 current_entry += n;3705 ++current_length;
95 unmodified lines
3801 c->delta_value = float32_unpack(get_bits(f, 32));3802 c->value_bits = get_bits(f, 4)+1;3803 c->sequence_p = get_bits(f,1);3804 if (c->lookup_type == 1) {3801 c->lookup_values = lookup1_values(c->entries, c->dimensions);3805 int values = lookup1_values(c->entries, c->dimensions);3806 if (values < 0) return error(f, VORBIS_invalid_setup);3807 c->lookup_values = (uint32) values;3808 } else {3809 c->lookup_values = c->entries * c->dimensions;3810 }3811 if (c->lookup_values == 0) return error(f, VORBIS_invalid_setup);
127 unmodified lines
3939 p[j].x = g->Xlist[j];3940 p[j].id = j;3941 }3942 qsort(p, g->values, sizeof(p[0]), point_compare);3943 for (j=0; j < g->values-1; ++j)3944 if (p[j].x == p[j+1].x)3945 return error(f, VORBIS_invalid_setup);3946 for (j=0; j < g->values; ++j)3947 g->sorted_order[j] = (uint8) p[j].id;3948 // precompute the neighbors3949 for (j=2; j < g->values; ++j) {
78 unmodified lines
4028 if (m->submaps > max_submaps)4029 max_submaps = m->submaps;4030 if (get_bits(f,1)) {4031 m->coupling_steps = get_bits(f,8)+1;4032 if (m->coupling_steps > f->channels) return error(f, VORBIS_invalid_setup);4033 for (k=0; k < m->coupling_steps; ++k) {4034 m->chan[k].magnitude = get_bits(f, ilog(f->channels-1));4035 m->chan[k].angle = get_bits(f, ilog(f->channels-1));4036 if (m->chan[k].magnitude >= f->channels) return error(f, VORBIS_invalid_setup);
1358 unmodified lines
5395}5396#endif // STB_VORBIS_NO_PULLDATA_API53975398/* Version history5399 1.17 - 2019-07-08 - fix CVE-2019-13217, -13218, -13219, -13220, -13221, -13223, -132235400 found with Mayhem by ForAllSecure5401 1.16 - 2019-03-04 - fix warnings5402 1.15 - 2019-02-07 - explicit failure if Ogg Skeleton data is found5403 1.14 - 2018-02-11 - delete bogus dealloca usage5404 1.13 - 2018-01-29 - fix truncation of last frame (hopefully)5405 1.12 - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files5406 1.11 - 2017-07-23 - fix MinGW compilation 5407 1.10 - 2017-03-03 - more robust seeking; fix negative ilog(); clear error in open_memory5408 1.09 - 2016-04-04 - back out 'avoid discarding last frame' fix from previous version
94 unmodified lines