Skip to content

Commit

Permalink
adplug: apply deadbeef patches
Browse files Browse the repository at this point in the history
adplug: hsc readBuf optimization

adplug: heap buffer overflow crash fix

adplug: heap buffer overflow crash fix

adplug: fix or suppress warnings when building in Xcode
  • Loading branch information
Oleksiy-Yakovenko committed Nov 2, 2024
1 parent cfb68f5 commit 5b118e7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
11 changes: 6 additions & 5 deletions plugins/adplug/adplug/hsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,24 @@ bool ChscPlayer::load(const std::string &filename, const CFileProvider &fp)
int total_patterns_in_hsc = (fp.filesize(f) - 1587) / 1152;

// load section
for(i=0;i<128*12;i++) // load instruments
*((unsigned char *)instr + i) = f->readInt(1);
f->readBuf ((char *)instr, 128*12);
for (i=0;i<128;i++) { // correct instruments
instr[i][2] ^= (instr[i][2] & 0x40) << 1;
instr[i][3] ^= (instr[i][3] & 0x40) << 1;
instr[i][11] >>= 4; // slide
}

f->readBuf ((char *)song, 51); // load tracklist

for(i=0;i<51;i++) { // load tracklist
song[i] = f->readInt(1);
// if out of range, song ends here
if (
((song[i] & 0x7F) > 0x31)
|| ((song[i] & 0x7F) >= total_patterns_in_hsc)
) song[i] = 0xFF;
}
for(i=0;i<50*64*9;i++) // load patterns
*((char *)patterns + i) = f->readInt(1);

f->readBuf ((char *)patterns, 50*64*9); // load patterns

fp.close(f);
rewind(0); // rewind module
Expand Down
2 changes: 1 addition & 1 deletion plugins/adplug/adplug/ksm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ bool CksmPlayer::load(const std::string &filename, const CFileProvider &fp)

bool CksmPlayer::update()
{
int quanter,chan,drumnum,freq,track,volevel,volval;
int quanter,chan = 0,drumnum = 0,freq,track,volevel,volval;
unsigned int i,j,bufnum;
unsigned long temp,templong;

Expand Down
5 changes: 5 additions & 0 deletions plugins/adplug/adplug/lds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,11 @@ void CldsPlayer::rewind(int subsong)
void CldsPlayer::playsound(int inst_number, int channel_number, int tunehigh)
{
Channel *c = &channel[channel_number]; // current channel

if (inst_number >= numpatch) {
inst_number = numpatch-1;
}

SoundBank *i = &soundbank[inst_number]; // current instrument
unsigned int regnum = op_table[channel_number]; // channel's OPL2 register
unsigned char volcalc, octave;
Expand Down
2 changes: 2 additions & 0 deletions plugins/adplug/adplug/raw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ bool CrawPlayer::update()
setspeed = false;
if (this->pos >= this->length) return false;

if (this->pos >= this->length) return false;

switch(this->data[this->pos].command) {
case 0:
this->del = this->data[this->pos].param - 1;
Expand Down
2 changes: 1 addition & 1 deletion plugins/adplug/adplug/woodyopl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ static void OPL_INLINE clipit8(Bit32s ival, Bit8s* outval) {
*outval = 0;
}
} else {
*outval = 255;
*outval = -1;
}
}

Expand Down

0 comments on commit 5b118e7

Please sign in to comment.