]>
Commit | Line | Data |
---|---|---|
be091c23 KK |
1 | changeset: 5320:d7f11bf8b7c8 |
2 | user: Tony Vroon <chainsaw@gentoo.org> | |
3 | date: Sun Jan 23 00:28:36 2011 +0000 | |
4 | summary: adplug: Two fixes (to protrack & rol) from Michael Schwendt, closes AUDPLUG-320. | |
5 | ||
6 | diff -r 9f9d51fa2975 -r d7f11bf8b7c8 src/adplug/core/protrack.cxx | |
7 | --- a/src/adplug/core/protrack.cxx Fri Jan 21 23:28:39 2011 -0500 | |
8 | +++ b/src/adplug/core/protrack.cxx Sun Jan 23 00:28:36 2011 +0000 | |
9 | @@ -266,6 +266,10 @@ | |
10 | else | |
11 | track--; | |
12 | ||
13 | + if (track >= npats*nchans) { // prevent overflow | |
14 | + songend = 1; | |
15 | + return !songend; | |
16 | + } | |
17 | AdPlug_LogWrite ("%3d%3d%2X%2X%2X|", tracks[track][row].note, | |
18 | tracks[track][row].inst, tracks[track][row].command, | |
19 | tracks[track][row].param1, tracks[track][row].param2); | |
20 | diff -r 9f9d51fa2975 -r d7f11bf8b7c8 src/adplug/core/rol.cxx | |
21 | --- a/src/adplug/core/rol.cxx Fri Jan 21 23:28:39 2011 -0500 | |
22 | +++ b/src/adplug/core/rol.cxx Sun Jan 23 00:28:36 2011 +0000 | |
23 | @@ -257,6 +257,9 @@ | |
24 | TVolumeEvents &vEvents = voiceData.volume_events; | |
25 | TPitchEvents &pEvents = voiceData.pitch_events; | |
26 | ||
27 | + if (iEvents.empty()) { | |
28 | + return; // prevent out-of-bounds access | |
29 | + } | |
30 | if( !(voiceData.mEventStatus & CVoiceData::kES_InstrEnd ) && | |
31 | iEvents[voiceData.next_instrument_event].time == mCurrTick ) | |
32 | { | |
33 | @@ -271,6 +274,9 @@ | |
34 | } | |
35 | } | |
36 | ||
37 | + if (vEvents.empty()) { | |
38 | + return; // prevent out-of-bounds access | |
39 | + } | |
40 | if( !(voiceData.mEventStatus & CVoiceData::kES_VolumeEnd ) && | |
41 | vEvents[voiceData.next_volume_event].time == mCurrTick ) | |
42 | { | |
43 | @@ -314,6 +320,9 @@ | |
44 | } | |
45 | } | |
46 | ||
47 | + if (pEvents.empty()) { | |
48 | + return; // prevent out-of-bounds access | |
49 | + } | |
50 | if( !(voiceData.mEventStatus & CVoiceData::kES_PitchEnd ) && | |
51 | pEvents[voiceData.next_pitch_event].time == mCurrTick ) | |
52 | { | |
53 | @@ -454,6 +463,9 @@ | |
54 | { | |
55 | int16 const num_tempo_events = f->readInt( 2 ); | |
56 | ||
57 | + if (num_tempo_events<0) { | |
58 | + return; | |
59 | + } | |
60 | mTempoEvents.reserve( num_tempo_events ); | |
61 | ||
62 | for(int i=0; i<num_tempo_events; ++i) | |
63 | @@ -538,6 +550,9 @@ | |
64 | binistream *bnk_file, SBnkHeader const &bnk_header ) | |
65 | { | |
66 | int16 const number_of_instrument_events = f->readInt( 2 ); | |
67 | + if (number_of_instrument_events<0) { | |
68 | + return; | |
69 | + } | |
70 | ||
71 | TInstrumentEvents &instrument_events = voice.instrument_events; | |
72 | ||
73 | @@ -563,6 +578,9 @@ | |
74 | void CrolPlayer::load_volume_events( binistream *f, CVoiceData &voice ) | |
75 | { | |
76 | int16 const number_of_volume_events = f->readInt( 2 ); | |
77 | + if (number_of_volume_events<0) { | |
78 | + return; | |
79 | + } | |
80 | ||
81 | TVolumeEvents &volume_events = voice.volume_events; | |
82 | ||
83 | @@ -583,6 +601,9 @@ | |
84 | void CrolPlayer::load_pitch_events( binistream *f, CVoiceData &voice ) | |
85 | { | |
86 | int16 const number_of_pitch_events = f->readInt( 2 ); | |
87 | + if (number_of_pitch_events<0) { | |
88 | + return; | |
89 | + } | |
90 | ||
91 | TPitchEvents &pitch_events = voice.pitch_events; | |
92 | ||
93 |