diff --git a/VERSION b/VERSION index 3773b88..66b8484 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -2021 May 23 2021 +2021 May 25 2021 diff --git a/abcmatch.c b/abcmatch.c index 8b98a19..9e5e505 100644 --- a/abcmatch.c +++ b/abcmatch.c @@ -49,7 +49,7 @@ Matching: -#define VERSION "1.78 March 27 2021 abcmatch" +#define VERSION "1.79 May 25 2021 abcmatch" #include #include #include diff --git a/doc/CHANGES b/doc/CHANGES index 94c31cb..03134fc 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -14240,3 +14240,14 @@ to get these options working again. +May 25 2021 + +James Allwright added more security checks to stop the +parser from reading numbers beyond the largest integer. Changes +were made to parserabc.c and midi2abc.c + +The abc2abc -s spacing function was modified to ignore certain +time signatures like M: none or M:7/8. The code for dealing with +3/2, 3/4, 3/8 ... time signatures was improved. + + diff --git a/doc/readme.txt b/doc/readme.txt index 89019bf..21c8f2c 100644 --- a/doc/readme.txt +++ b/doc/readme.txt @@ -1,10 +1,10 @@ abcMIDI : abc <-> MIDI conversion utilities -midi2abc version 3.47 November 01 2020 -abc2midi version 4.56 May 21 2021 -abc2abc version 2.13 May 08 2021 -yaps version 1.86 December 10 2020 -abcmatch version 1.78 March 27 2021 +midi2abc version 3.47 May 25 2021 +abc2midi version 4.57 May 25 2021 +abc2abc version 2.15 May 25 2021 +yaps version 1.87 May 25 2021 +abcmatch version 1.79 May 25 2021 midicopy version 1.37 October 10 2020 24th January 2002 diff --git a/midi2abc.c b/midi2abc.c index 9061e2c..c36105e 100644 --- a/midi2abc.c +++ b/midi2abc.c @@ -45,8 +45,9 @@ * based on public domain 'midifilelib' package. */ -#define VERSION "3.47 November 01 2020 midi2abc" +#define VERSION "3.48 May 25 2021 midi2abc" +#include /* Microsoft Visual C++ Version 6.0 or higher */ #ifdef _MSC_VER #define snprintf _snprintf @@ -3451,7 +3452,8 @@ char *num; p = p + 1; neg = -1; }; - while (((int)*p >= '0') && ((int)*p <= '9')) { + /* [JA] 2021-05-25 */ + while (((int)*p >= '0') && ((int)*p <= '9') && (t < (INT_MAX-9)/10)) { t = t * 10 + (int) *p - '0'; p = p + 1; }; @@ -3467,10 +3469,15 @@ char **p; int t; t = 0; - while (((int)**p >= '0') && ((int)**p <= '9')) { + /* [JA] 2021-05-25 */ + while (((int)**p >= '0') && ((int)**p <= '9') && (t < (INT_MAX-9)/10)) { t = t * 10 + (int) **p - '0'; *p = *p + 1; }; + /* advance over any spurious extra digits */ + while (isdigit(**p)) { + *p = *p + 1; + } return t; } diff --git a/parseabc.c b/parseabc.c index 81b471c..b5c36c3 100644 --- a/parseabc.c +++ b/parseabc.c @@ -37,6 +37,7 @@ #include /* [JM] 2018-02-22 to handle strncasecmp() */ #include +#include /* #define SIZE_ABBREVIATIONS ('Z' - 'H' + 1) [SS] 2016-09-20 */ #define SIZE_ABBREVIATIONS 58 @@ -348,11 +349,15 @@ readnumf (num) event_error ("Missing Number"); }; t = 0; - while (((int) *p >= '0') && ((int) *p <= '9')) +/* [JA] 2021-05-25 */ + while (((int) *p >= '0') && ((int) *p <= '9') && (t < (INT_MAX-9)/10)) { t = t * 10 + (int) *p - '0'; p = p + 1; }; + if (t >= (INT_MAX-9)/10) { /* [JA] 2021-05-25 */ + event_error ("Number too big"); + } return (t); } @@ -384,11 +389,16 @@ readnump (p) int t; t = 0; - while (((int) **p >= '0') && ((int) **p <= '9')) - { - t = t * 10 + (int) **p - '0'; - *p = *p + 1; - }; + /* [JA] 2021-05-25 */ + while (((int) **p >= '0') && ((int) **p <= '9') && (t < (INT_MAX-9)/10)) + { + t = t * 10 + (int) **p - '0'; + *p = *p + 1; + } + /* advance over any spurious extra digits [JA] 2021-05-25 */ + while (isdigit(**p)) { + *p = *p + 1; + } return (t); } diff --git a/store.c b/store.c index 819c7e6..2b59f7f 100644 --- a/store.c +++ b/store.c @@ -186,7 +186,7 @@ int main() */ -#define VERSION "4.56 May 21 2021 abc2midi" +#define VERSION "4.57 May 25 2021 abc2midi" /* enables reading V: indication in header */ #define XTEN1 1 diff --git a/toabc.c b/toabc.c index f13371f..56eab22 100644 --- a/toabc.c +++ b/toabc.c @@ -21,7 +21,7 @@ /* back-end for outputting (possibly modified) abc */ -#define VERSION "2.14 May 09 2021 abc2abc" +#define VERSION "2.15 May 25 2021 abc2abc" /* for Microsoft Visual C++ 6.0 or higher */ #ifdef _MSC_VER @@ -84,6 +84,7 @@ struct fract breakpoint; /* used to break bar into beamed sets of notes */ complex_barpoint_t master_bar_break; int barno; /* number of bar within tune */ int newspacing; /* was -s option selected ? */ +int have_spacing_scheme; /* do we support spacing for time signature ? [JA] */ int barcheck; /* indicate -b and -r options selected */ int echeck; /* was error-checking turned off ? (-e option) */ int newbreaks; /* was -n option selected ? */ @@ -575,6 +576,7 @@ char** filename; } else { newspacing = 1; }; + have_spacing_scheme = 0; /* [JA] 2021-05-25 */ narg = getarg("-X", argc, argv); if (narg == -1) { newrefnos = 0; @@ -1414,6 +1416,7 @@ static void set_complex_barpoint(timesig_details_t *timesig, void event_timesig (timesig) timesig_details_t *timesig; { + have_spacing_scheme = 0; /* default to no new spacing */ emit_string ( "M:"); switch (timesig->type) { default: @@ -1459,6 +1462,7 @@ void event_timesig (timesig) set_complex_barpoint( ¤t_voice->timesig, &toabc_voice->bar_break); } + have_spacing_scheme = 1; /* [JA] 2021-05-25 */ } break; } @@ -1470,16 +1474,28 @@ void event_timesig (timesig) breakpoint.num = timesig->num; breakpoint.denom = timesig->denom; + if (timesig->num == 3) { /* [JA] 2021-05-25 */ + /* handles 3/2, 3/4, 3/8 */ + breakpoint.num = timesig->num / 3; + breakpoint.denom = timesig->denom; + have_spacing_scheme = 1; + } if ((timesig->num == 9) || (timesig->num == 6)) { breakpoint.num = 3; breakpoint.denom = barlen.denom; + have_spacing_scheme = 1; }; if (timesig->num % 2 == 0) { breakpoint.num = barlen.num / 2; breakpoint.denom = barlen.denom; + have_spacing_scheme = 1; }; barend = timesig->num / breakpoint.num; } + if (newspacing && !have_spacing_scheme) { + /* [JA] 2021-05-25 */ + event_warning ("Do not know how to group notes in this time signature"); + } inmusic = 0; } @@ -1874,7 +1890,7 @@ char* replist; void event_space() { - if (!newspacing) { + if (!(newspacing && have_spacing_scheme)) { emit_string(" "); }; } @@ -1929,7 +1945,7 @@ int n, q, r; if (tuplenotes != 0) { event_error("tuple within tuple not allowed"); }; - if (newspacing) { + if (newspacing && have_spacing_scheme) { emit_char(' '); } emit_int_sprintf("(%d", n); @@ -2504,7 +2520,7 @@ int xoctave, n, m; if ((!ingrace) && (!inchord)) { addunits(n, m); }; - if (newspacing) { + if (newspacing && have_spacing_scheme) { consider_break_after_note(prev_tuplenotes); }; } @@ -2594,7 +2610,7 @@ int xoctave, n, m; if ((!ingrace) && (!inchord)) { addunits(n, m); }; - if (newspacing) { + if (newspacing && have_spacing_scheme) { barpoint.num = count.num * breakpoint.denom; barpoint.denom = breakpoint.num * count.denom; reduce(&barpoint.num, &barpoint.denom); diff --git a/yapstree.c b/yapstree.c index c193b79..cb49711 100644 --- a/yapstree.c +++ b/yapstree.c @@ -22,7 +22,7 @@ /* yapstree.c - back-end for abc parser. */ /* generates a data structure suitable for typeset music */ -#define VERSION "1.86 December 10 2020 yaps" +#define VERSION "1.87 May 25 2021 yaps" #include #ifdef USE_INDEX #define strchr index