Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
f3c1b47
ABC: transpose only needs to look at notes (<26)
Konstanty May 28, 2017
d7890bd
Check memory position isn't over the memory length
Konstanty May 28, 2017
04b7eaf
Initialize nPatterns to 0 earlier
Konstanty May 31, 2017
f0c1ff2
ABC: Ensure for loop does not increment past end of loop
Konstanty May 31, 2017
d387dfd
ABC: Use blankline more often
Konstanty May 31, 2017
ca73f52
ABC: abort early if macro would be blank
Konstanty May 31, 2017
22b2b3c
ABC: avoid possibility of incrementing *p
Konstanty May 31, 2017
b4867d7
ABC: clean up loop exiting code
Konstanty Jun 1, 2017
0b0d113
ABC: ensure array access is bounded correctly.
Konstanty Jun 1, 2017
675ab5d
ABC: initialize earlier
Konstanty Jun 1, 2017
eabcd64
OKT: ensure file size is enough to contain data
Konstanty Jun 1, 2017
23ded13
WAV: check that there is space for both headers
Konstanty Jun 1, 2017
9f7821a
ABC: cleanup tracks correctly.
Konstanty Jun 2, 2017
347eeb8
PSM: make sure reads occur of only valid ins
Konstanty Jun 2, 2017
1162fd5
ABC: 10 digit ints require null termination
Konstanty Jun 2, 2017
d0adf30
FAR: out by one on check
Konstanty Jun 2, 2017
5163a38
OKT: add one more bound check
Konstanty Jun 2, 2017
f82b63a
ABC: terminate early when things don't work in substitute
Konstanty Jun 2, 2017
cdc0842
ABC: ensure read pointer is valid before incrementing
Konstanty Jun 8, 2017
4d0bc15
ABC: prevent possible increment of p past end
Konstanty Jun 9, 2017
f6dd59a
PSM: add missing line to commit
Konstanty Jun 9, 2017
1db0c41
OKT: increase bound check at start to 12.
Konstanty Aug 11, 2019
083e662
MED: Ensure that there is room to read one double
Konstanty Aug 11, 2019
5523dd6
MDL: make sure there is enough space to read the UINT
Konstanty Aug 11, 2019
5f4ef8b
XM: OOB fixes- don't read items outside 'packsize'
Konstanty Aug 11, 2019
1fbf435
MT2: OOB read fixes
Konstanty Aug 11, 2019
57a5cf1
MDL: OOB read fixes
Konstanty Aug 11, 2019
2314d9e
ABC: where char is lower case, allow another octave.
Konstanty Aug 12, 2019
43f0fc4
STM: make sure patterns are not loaded above the maximum size
Konstanty Aug 13, 2019
1cde769
ABC: bound divider to not be below 1.
Konstanty Aug 13, 2019
187d2da
MED: fix incorrect logic in previous bound check
Konstanty Aug 13, 2019
f0b1b4e
MID: add bound checking in read functions
Konstanty Aug 13, 2019
afa4f8e
MT2: check for overflow in comparison
Konstanty Aug 13, 2019
01f02dc
OKT: follow the convention of subtracting from total length
Konstanty Aug 13, 2019
1df97f9
MED: several logic errors when selecting str bounds
Konstanty Aug 23, 2019
8fc8670
MT2: ensure bound checking is done by subtracting from length
Konstanty Aug 23, 2019
645d90e
MMCMP: add bound check when almost at the end
Konstanty Aug 23, 2019
6339dfc
ABC: don't increment p unless its non null
Konstanty Aug 24, 2019
dd05578
MMCMP: fix subblk check for other path
Konstanty Aug 24, 2019
b7217c0
Merge branch 'master' into oob_read_fixes
Konstanty Aug 24, 2019
57c038a
669,MOD: keep private functions static
Konstanty Aug 24, 2019
04c5d45
Fix misc. bugs found by libfuzzer.
AliceLR Jun 13, 2021
aea13cc
Fix MIDI loader crash caused by undersized message buffer.
AliceLR Jun 13, 2021
96a4c49
Fix out-of-bounds read in PAT loader caused by invalid GM patches.
AliceLR Jun 13, 2021
f145d21
Fix MIDI loader crashes when tr->workevent is NULL.
AliceLR Jun 13, 2021
b04985a
Fix more PSM breakage introduced by #36, 6e384790.
AliceLR Jun 14, 2021
401a3f3
Fix crash in PSM loader from invalid sample numbers in pattern data.
AliceLR Jun 14, 2021
e26e8dd
Fix crash in MDL loader caused by bad instrument data bounding.
AliceLR Jun 14, 2021
e67185d
Fix crash in MDL loader caused by bad track bounding.
AliceLR Jun 14, 2021
d95ee0d
Fix MT2 loader crashes caused by bad instrument bounding.
AliceLR Jun 14, 2021
094c3a1
Fix another MDL track bounding bug.
AliceLR Jun 14, 2021
2e8cc41
Fix instrument leaks in DBM loader.
AliceLR Jun 14, 2021
2af03d9
Fix MT2 out-of-bounds nDrumDataLen read.
AliceLR Jun 14, 2021
9c8cac1
Fix crash in MT2 loader caused by faulty group bounds check.
AliceLR Jun 14, 2021
37ca347
Fix MT2 out-of-bounds reads caused by various faulty/missing checks.
AliceLR Jun 14, 2021
3526aa2
Fix STM pattern leaks and pattern size corruption.
AliceLR Jun 14, 2021
8253cac
Fix MDL crashes due to bad envelope bounding and duplicate envelope c…
AliceLR Jun 14, 2021
8bdf601
Revise new MDL instrument sample struct bounds check.
AliceLR Jun 14, 2021
14c4506
Fix out-of-bounds read in XM pattern loader.
AliceLR Jun 14, 2021
c078f24
Fix MED loader out-of-bounds reads caused by bad sample bounding.
AliceLR Jun 15, 2021
6b2eac7
Revise MT2 instrument sample bounds checks.
AliceLR Jun 15, 2021
fa36b80
Fix hang in DMF loader caused by duplicate PATT chunks.
AliceLR Jun 15, 2021
d620a46
Fix out-of-bounds read in MDL loader due to missing info chunk bounds…
AliceLR Jun 15, 2021
be99ce4
Fix MMCMP out-of-bounds read due to broken subblock bounds checking.
AliceLR Jun 15, 2021
d264a9d
Also fix potential bug in the remaining MMCMP subblock bounds check.
AliceLR Jun 15, 2021
647843d
Fix hang in MT2 loader caused by very large extra data chunk sizes.
AliceLR Jun 15, 2021
29cc57e
Fix MED block name bounding, always nul-terminate block name.
AliceLR Jun 16, 2021
3389523
Fix MT2 crash caused by missing sample data length bounds check.
AliceLR Jun 16, 2021
772a719
Fix/cleanup MMCMP bounds checks to reduce slow loads.
AliceLR Jun 17, 2021
8b19c81
Revise DMF duplicate pattern check to prevent hangs.
AliceLR Jun 18, 2021
7564bf2
Revise OKT loader PATT bounding, import fix from #53.
AliceLR Jun 18, 2021
00125a6
Fix DMF bounding for INFO, SEQU, and SMPI chunks.
AliceLR Jun 18, 2021
74dff27
Improve DMF pattern bounding.
AliceLR Jun 18, 2021
f39b8c3
Fix DMF slow loads caused by missing DMFUnpack EOF check.
AliceLR Jun 19, 2021
77a1424
Fix DMF sample leaks caused by duplicate SMPD chunks.
AliceLR Jun 19, 2021
1bef4e1
Add bounds checks to Extreme's Tracker AMS loader.
AliceLR Jun 19, 2021
11871de
Fix Velvet Studio AMS crash, constify pointers.
AliceLR Jun 19, 2021
31910e1
Fix another Extreme's AMS crash.
AliceLR Jun 19, 2021
ecf8df0
Fix AMS slow loads due to large garbage samples.
AliceLR Jun 19, 2021
6948105
Fix AMS2 instrument bounding checks.
AliceLR Jun 19, 2021
4282f68
Add more missing consts in AMS loaders.
AliceLR Jun 19, 2021
5e1443f
Add missing AMSUnpack bounds checks.
AliceLR Jun 19, 2021
2ff82c3
Fix AMS sample packed length bounding.
AliceLR Jun 19, 2021
19a5370
Revise MIDI debug message fix to still use sprintf instead of snprintf.
AliceLR Jun 19, 2021
89b591f
Add missing DMF sample bounds check.
AliceLR Jun 19, 2021
d8ee117
Fix WAV fmt header bounds check, add consts to WAV loader.
AliceLR Jun 20, 2021
cd6baf2
Shrink AMS samples if the packed size can't possibly fit them.
AliceLR Jun 20, 2021
38a7b2f
Fix hang in WAV loader caused by missing chunk length check.
AliceLR Jun 20, 2021
f2c6827
Fix XM slow loads caused by bad instrument checks, fix other checks.
AliceLR Jun 21, 2021
6dfcfed
Revise FAR max pattern length bounding to be more readable.
AliceLR Jun 21, 2021
70d73b9
Fix off-by-one AMS pattern bounds checks.
AliceLR Jun 22, 2021
f768b60
Add extra AMS2 pitchenv bounds check in case support is ever added fo…
AliceLR Jun 22, 2021
4317cb7
Add missing DMF track bounds check, tweak for consistency.
AliceLR Jun 22, 2021
5306ac8
Merge branch 'master' into oob_read_fixes
Konstanty Jan 28, 2022
1e38a97
Merge branch 'master' into oob_read_fixes
Konstanty Jan 28, 2022
6c5cb42
Merge branch 'oob_read_fixes' of github.com:Konstanty/libmodplug into…
Konstanty Jan 28, 2022
1eec55f
Merge branch 'fuzz-patch-1-original' of https://github.com/AliceLR/li…
Konstanty Jan 28, 2022
7c1c3aa
Merge branch 'AliceLR-fuzz-patch-1-original' into oob_read_fixes
Konstanty Jan 28, 2022
d04fbc2
Increment version 0.8.9.1
Konstanty Jan 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
dnl Process this file with autoconf to produce a configure script.

AC_PREREQ(2.63)
AC_PREREQ([2.71])

AC_INIT([libmodplug], [0.8.9.0])
AC_INIT([libmodplug],[0.8.9.1])
AC_CONFIG_SRCDIR([Makefile.am])

AM_INIT_AUTOMAKE
Expand All @@ -12,12 +12,6 @@ AC_CONFIG_MACRO_DIR([m4])
AM_MAINTAINER_MODE([enable])

dnl Checks for programs.
dnl I am disabling static libraries here because otherwise libtool insists on
dnl compiling everything twice -- once with and once without -fPIC. Pisses me
dnl off. Just do everything with -fPIC, damnit! Compiling everything twice
dnl probably wastes more cycles than not using -fPIC saves.
AC_DISABLE_STATIC
AC_DISABLE_STATIC([])
AC_PROG_CC
AC_PROG_CXX
AC_LANG([C++])
Expand All @@ -27,7 +21,15 @@ AC_C_BIGENDIAN
#AC_PROG_LIBTOOL
LT_INIT([win32-dll])

AC_HEADER_STDC
m4_warn([obsolete],
[The preprocessor macro `STDC_HEADERS' is obsolete.
Except in unusual embedded environments, you can safely include all
ISO C90 headers unconditionally.])dnl
# Autoupdate added the next two lines to ensure that your configure
# script's behavior did not change. They are probably safe to remove.
AC_CHECK_INCLUDES_DEFAULT
AC_PROG_EGREP

AC_CHECK_HEADERS([inttypes.h stdint.h malloc.h])
AC_CHECK_FUNCS(setenv sinf)

Expand Down Expand Up @@ -55,11 +57,8 @@ esac
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -fvisibility=hidden -Werror"
AC_CACHE_CHECK([if compiler supports visibility attributes],[libmodplug_cv_gcc_visibility],
AC_TRY_COMPILE([void foo(void);
__attribute__((visibility("default"))) void foo(void) {}],
[],
[libmodplug_cv_gcc_visibility=yes],
[libmodplug_cv_gcc_visibility=no])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[void foo(void);
__attribute__((visibility("default"))) void foo(void) {}]], [[]])],[libmodplug_cv_gcc_visibility=yes],[libmodplug_cv_gcc_visibility=no])
)
# we want symbol -fvisibility for elf targets, however it works
# with darwin/macho too. other than that, windows, dos and os2
Expand Down
2 changes: 1 addition & 1 deletion src/load_669.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ typedef struct tagSAMPLE669
BYTE loopend[4];
} SAMPLE669;

DWORD lengthArrayToDWORD(const BYTE length[4]) {
static DWORD lengthArrayToDWORD(const BYTE length[4]) {
DWORD len = (length[3] << 24) +
(length[2] << 16) +
(length[1] << 8) +
Expand Down
64 changes: 38 additions & 26 deletions src/load_abc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,10 @@ static int abc_transpose(const char *v)
if( j ) {
while( *v && *v != ' ' && *v != ']' ) v++;
}

// Already reached the end of the string..
if (!*v)
break;
}
if( strlen(mv) > 0 ) // someone set the middle note
t += abc_interval(mv, m);
Expand Down Expand Up @@ -1282,6 +1286,9 @@ static int abc_add_noteon(ABCHANDLE *h, int ch, const char *p, uint32_t tracktim
i = 0;
break;
}
// nothing good inside - early exit
if ( n == 0 )
return 0;
for( k=0; k<51; k++ ) {
if( n == barkey[k] )
break;
Expand Down Expand Up @@ -1484,7 +1491,7 @@ static void abc_add_chord(const char *p, ABCHANDLE *h, ABCTRACK *tp, uint32_t tr
d[chordnote] = i;
break;
}
p++;
if (*p) p++;
switch(*p) {
case 'b':
d[chordnote]--;
Expand All @@ -1506,7 +1513,7 @@ static void abc_add_chord(const char *p, ABCHANDLE *h, ABCTRACK *tp, uint32_t tr
d[chordbase] = i;
break;
}
p++;
if (*p) p++;
switch(*p) {
case 'b':
d[chordbase]--;
Expand Down Expand Up @@ -1655,6 +1662,7 @@ static int abc_notelen(const char *p, int *len, int *div)
else k = 1;
*div = h * k;
if ( *div > 4096 ) *div = 4096;
if ( *div <= 0 ) *div = 1;
return i;
}

Expand Down Expand Up @@ -2004,7 +2012,7 @@ static uint32_t abc_fade_tracks(ABCHANDLE *h, char *abcparts, uint32_t ptt[27])
tp->slidevoltime = e0->tracktick;
}
tp->mute = 0; // unmute track for safety, notes in a muted track already have zero volume...
while( vol > 5 ) {
while( vol > 5 && tp->slidevoltime != 0) {
for( p=abcparts; *p && vol > 5; p++ ) {
pt1 = ptt[*p-'A'];
pt2 = ptt[*p-'A'+1];
Expand All @@ -2023,7 +2031,7 @@ static void abc_song_to_parts(ABCHANDLE *h, char **abcparts, BYTE partp[27][2])
ABCEVENT *e;
int i, fading, loop, normal, partno, partsegno, partloop, partcoda, parttocoda, partfine, skip, x, y;
int vmask[27],nextp[27];
uint32_t ptt[27];
uint32_t ptt[27] = {};
char buf[256]; // must be enough, mod's cannot handle more than 240 patterns
char *pfade;
if( !h || !h->track || !h->track->capostart ) return;
Expand Down Expand Up @@ -2147,7 +2155,8 @@ static void abc_song_to_parts(ABCHANDLE *h, char **abcparts, BYTE partp[27][2])
if( buf[i] != buf[i-1] + 1 ) {
x = buf[i-1] - 'A';
y = buf[i] - 'A';
abc_keeptiednotes(h, ptt[x+1], ptt[y]);
if (x < 26 && y < 26)
abc_keeptiednotes(h, ptt[x+1], ptt[y]);
}
}
}
Expand Down Expand Up @@ -2220,6 +2229,8 @@ static void abc_substitute(ABCHANDLE *h, char *target, char *s)
strcpy(p,s);
for( q=p+l; *q; q++ ) *p++ = *q;
}
// ensure end of string is initialized
*p = 0;
}
}

Expand All @@ -2239,7 +2250,7 @@ static void abc_preprocess(ABCHANDLE *h, ABCMACRO *m)
a = m->subst[j];
if( a > 'g' && islower(a) ) {
b = a - 'n';
a = "CDEFGABCDEFGABcdefgabcdefgab"[i+b+7];
a = "CDEFGABCDEFGABcdefgabcdefgabcdefgab"[i+b+7];
*p++ = a;
if( i+b < 0 )
*p++ = ',';
Expand Down Expand Up @@ -2290,12 +2301,12 @@ static int abc_parse_decorations(ABCHANDLE *h, ABCTRACK *tp, const char *p)
if( !strncmp(p,"sfz",3) ) vol = 100;
if( *p == 'p' ) {
vol = 60;
while( *p++ == 'p' ) vol -= 15;
while( *p && *p++ == 'p' ) vol -= 15;
if( vol < 1 ) vol = 1;
}
if( *p == 'f' ) {
vol = 105;
while( *p++ == 'f' ) vol += 15;
while( *p && *p++ == 'f' ) vol += 15;
if( vol > 135 ) vol = 127; // ffff
if( vol > 127 ) vol = 125; // fff
}
Expand Down Expand Up @@ -2379,7 +2390,7 @@ static ABCHANDLE *ABC_Init(void)
return retval;
}

static void ABC_CleanupTrack(ABCTRACK *tp)
static void ABC_CleanupTrackEvents(ABCTRACK *tp)
{
ABCEVENT *ep, *en;
if( tp ) {
Expand Down Expand Up @@ -2408,7 +2419,8 @@ static void ABC_CleanupTracks(ABCHANDLE *handle)
if(handle) {
for( tp=handle->track; tp; tp = tn ) {
tn=tp->next;
ABC_CleanupTrack(tp);
ABC_CleanupTrackEvents(tp);
free(tp);
}
handle->track = NULL;
}
Expand Down Expand Up @@ -3391,6 +3403,7 @@ static int abc_partpat_to_orderlist(BYTE partp[27][2], const char *abcparts, ABC
if( abcparts ) {
partsused = 0;
for( p = abcparts; *p; p++ ) {
if (*p < 'A' || *p > 'Z') break;
for( t = partp[*p - 'A'][0]; t < partp[*p - 'A'][1]; t++ ) {
if( orderlen == ordersize ) {
ordersize <<= 1;
Expand Down Expand Up @@ -3572,8 +3585,8 @@ BOOL CSoundFile::ReadABC(const uint8_t *lpStream, DWORD dwMemLength)
char *line, *p, *pp, ch, ch0=0;
char barsig[52]; // for propagated accidental key signature within bar
char *abcparts;
uint8_t partpat[27][2], *orderlist;
int orderlen;
uint8_t partpat[27][2], *orderlist = NULL;
int orderlen = 0;
enum { NOWHERE, INBETWEEN, INHEAD, INBODY, INSKIPFORX, INSKIPFORQUOTE } abcstate;
ABCEVENT_JUMPTYPE j;
ABCEVENT_X_EFFECT abceffect;
Expand Down Expand Up @@ -3663,8 +3676,6 @@ BOOL CSoundFile::ReadABC(const uint8_t *lpStream, DWORD dwMemLength)
abc_init_partpat(partpat);
abc_MIDI_beat(h, ""); // reset beat array
abc_MIDI_beatstring(h, ""); // reset beatstring
orderlist = NULL;
orderlen = 0;
mmsp = 1;
mmstack[0] = mmfile;
mmfseek(mmfile,0,SEEK_SET);
Expand All @@ -3687,7 +3698,7 @@ BOOL CSoundFile::ReadABC(const uint8_t *lpStream, DWORD dwMemLength)
while( mmsp > 0 ) {
mmsp--;
while((line=abc_gets(h, mmstack[mmsp]))) {
char blankline[3] = "%%";
char blankline[3] = "% ";
for( p=line; isspace(*p); p++ ) ;
switch(abcstate) {
case INSKIPFORX:
Expand Down Expand Up @@ -3800,7 +3811,7 @@ BOOL CSoundFile::ReadABC(const uint8_t *lpStream, DWORD dwMemLength)
sprintf(barsig, "%s%s", sig[abckey], sig[abckey]); // reset the key signature
p = abc_skip_word(p+2);
h->ktrans = abc_transpose(p);
*p = '%'; // force skip rest of line
p = blankline; // force skip rest of line
if( snotelen == 0 ) { // calculate default notelen from meter M:
if( mnotediv == 0 ) mnotediv = mnotelen = 1; // do'nt get nuked
snotelen = 100 * mnotelen / mnotediv;
Expand Down Expand Up @@ -3893,7 +3904,7 @@ BOOL CSoundFile::ReadABC(const uint8_t *lpStream, DWORD dwMemLength)
sprintf(barsig, "%s%s", sig[abckey], sig[abckey]); // reset the key signature
p = abc_skip_word(p+2);
h->ktrans = abc_transpose(p);
*p = '%'; // make me skip the rest of the line....
p = blankline; // make me skip the rest of the line....
}
if( !strncmp(p,"L:",2) ) {
sscanf(p+2," %d / %d", &snotelen, &snotediv);
Expand Down Expand Up @@ -3934,7 +3945,8 @@ BOOL CSoundFile::ReadABC(const uint8_t *lpStream, DWORD dwMemLength)
char *pm = p;
if (mmstack[mmsp]->pos < dwMemLength) {
pm = abc_continuated(h, mmstack[mmsp], p);
abc_new_macro(h, pm+2);
if (pm+2)
abc_new_macro(h, pm+2);
}
if( pm != p ) {
free(pm);
Expand Down Expand Up @@ -4060,7 +4072,7 @@ BOOL CSoundFile::ReadABC(const uint8_t *lpStream, DWORD dwMemLength)
// plough thru the songline gathering mos....
ch0 = ' ';
pp = 0;
while( (ch = *p++) ) {
while( *p && (ch = *p++) ) {
if( !pp && isalpha(ch) && *p != ':' ) { // maybe a macro
for( mp=h->umacro; mp; mp=mp->next ) {
if( ch == mp->name[0] ) {
Expand Down Expand Up @@ -4156,15 +4168,15 @@ BOOL CSoundFile::ReadABC(const uint8_t *lpStream, DWORD dwMemLength)
break;
}
if( *p && strchr("abcdefgABCDEFG^_=",*p) ) {
int cnl[8],cnd[8],vnl,nl0=0,nd0=0,barticks; // for chords with notes of varying length
int cnl[8]={},cnd[8]={},vnl,nl0=0,nd0=0,barticks; // for chords with notes of varying length
barticks = notelen_notediv_to_ticks(h->speed,1,mnotediv);
if (barticks == 0) barticks = 1;
abcchord = 0;
vnl = 0;
h->tp = abc_check_track(h, h->tp);
abc_track_clear_tiedvpos(h);
abcbeatvol = abc_beat_vol(h, abcvol, (h->tracktime - bartime)/barticks);
while( (ch=*p++) && (ch != ']') ) {
while( *p && (ch=*p++) && (ch != ']') ) {
h->tp = abc_locate_track(h, h->tp->v, abcchord? abcchord+DRONEPOS2: 0);
p += abc_add_noteon(h, ch, p, h->tracktime, barsig, abcbeatvol, abceffect, abceffoper);
p += abc_notelen(p, &notelen, &notediv);
Expand Down Expand Up @@ -4332,7 +4344,7 @@ BOOL CSoundFile::ReadABC(const uint8_t *lpStream, DWORD dwMemLength)
int barticks = notelen_notediv_to_ticks(h->speed,1,mnotediv);
if (barticks == 0) barticks = 1;
abcbeatvol = abc_beat_vol(h, abcvol, (h->tracktime - bartime)/barticks);
while( (ch=*p++) && (ch != '}') ) {
while( *p && (ch=*p++) && (ch != '}') ) {
p += abc_add_noteon(h, ch, p, h->tracktime+abcgrace, barsig, abcbeatvol, none, 0);
p += abc_notelen(p, &notelen, &notediv);
if( *p=='-' ) {
Expand Down Expand Up @@ -4418,7 +4430,7 @@ BOOL CSoundFile::ReadABC(const uint8_t *lpStream, DWORD dwMemLength)
if( h->tp == h->tpc ) abc_add_chord(p, h, h->tpc, h->tracktime); // only do chords for one voice
}
abcto = 0;
while( (ch=*p++) && (ch != '"') ) {
while( *p && (ch=*p++) && (ch != '"') ) {
if( !strncasecmp(p,"fade",4) && h->track && h->track->slidevol > -2 )
abc_globalslide(h, h->tracktime, -2); // set volumeslide to fade away...
if( !strncasecmp(p,"to coda",7) ) {
Expand Down Expand Up @@ -4627,7 +4639,7 @@ BOOL CSoundFile::ReadABC(const uint8_t *lpStream, DWORD dwMemLength)
else {
h->tp = abc_check_track(h, h->tp);
abcvol = abc_parse_decorations(h, h->tp, p);
while( (ch=*p++) && (ch != '+') )
while( *p && (ch=*p++) && (ch != '+') )
;
}
break;
Expand Down Expand Up @@ -4760,8 +4772,8 @@ BOOL CSoundFile::ReadABC(const uint8_t *lpStream, DWORD dwMemLength)
}
ABC_CleanupMacros(h); // we dont need them anymore
if( !h->track ) {
char buf[10];
sprintf(buf,"%u",abcxnumber);
char buf[11];
sprintf(buf,"%u", abcxnumber);
abc_message("abc X:%s has no body", buf);
h->track = abc_check_track(h, h->track); // for sanity...
}
Expand Down
5 changes: 5 additions & 0 deletions src/load_amf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,20 @@ BOOL CSoundFile::ReadAMF(LPCBYTE lpStream, const DWORD dwMemLength)
// Setup sequence list
for (UINT iOrd=0; iOrd<MAX_ORDERS; iOrd++)
{
if (dwMemPos + 4 > dwMemLength) return TRUE;
Order[iOrd] = 0xFF;
if (iOrd < pfh->numorders)
{
Order[iOrd] = iOrd;
PatternSize[iOrd] = 64;
if (pfh->version >= 14)
{
if (dwMemPos + m_nChannels * sizeof(USHORT) + 2 > dwMemLength) return FALSE;
PatternSize[iOrd] = bswapLE16(*(USHORT *)(lpStream+dwMemPos));
dwMemPos += 2;
} else
{
if (dwMemPos + m_nChannels * sizeof(USHORT) > dwMemLength) return FALSE;
}
ptracks[iOrd] = (USHORT *)(lpStream+dwMemPos);
dwMemPos += m_nChannels * sizeof(USHORT);
Expand Down
Loading