1
0
Fork 0
forked from len0rd/rockbox

Allow cuesheet index offsets longer than 99 minutes.

While the track number is limited to 99, I know of no documented
constraint on the value of offset minutes to 99.

As we are storing the millisecond offset as unsigned long, assuming
32 bit, we can allow 70,000 minutes (2^32 / 60000).

However, I've been unable to generate a test audio file 48 days long
under 2GB, so I've set the limit to 30,000 minutes.

In addition, this change reduces the maximum number of seconds to 59,
and frames to 74.

I've generated some silent test files with the filenames being
cue_[minutes].mp3

http://peskett.co.uk/rockbox/test_cues/

Change-Id: I3ca4468ebc88ba134c4e785e9395f90bf76941ac
This commit is contained in:
Nick Peskett 2022-04-07 09:08:50 +00:00 committed by William Wilgus
parent d1be73cfc0
commit db55d30372

View file

@ -123,6 +123,7 @@ static unsigned long parse_cue_index(const char *line)
/* assumes strncmp(line, "INDEX 01", 8) & NULL terminated string */
/* INDEX 01 MM:SS:FF\0 (00:00:00\0 - 99:99:99\0)*/
const unsigned field_m[3] = {60 * 1000, 1000, 13}; /* MM:SS:~FF*/
const unsigned field_max[3] = {30000, 59, 74}; /* MM, SS, FF */
const char f_sep = ':';
int field = -1;
unsigned long offset = 0; /* ms from start of track */
@ -138,7 +139,7 @@ static unsigned long parse_cue_index(const char *line)
while (isdigit(*line))
{
value = 10 * value + (*line - '0');
if (value > 99) /* Sanity check bail early */
if (value > field_max[field]) /* Sanity check bail early */
return 0;
line++;
}