1
0
Fork 0
forked from len0rd/rockbox

Prevent two division by zeros and one problem causing a crash in the

mp3 metadata parser.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9438 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Miika Pekkarinen 2006-04-02 20:19:00 +00:00
parent ea6b4cbe4f
commit 93b6a1d12c
3 changed files with 19 additions and 2 deletions

View file

@ -629,7 +629,10 @@ void dsp_set_eq_coefs(int band)
cutoff = 0xffffffff / NATIVE_FREQUENCY * (*setting++);
q = ((*setting++) << 16) / 10; /* 16.16 */
gain = ((*setting++) << 16) / 10; /* s15.16 */
if (q == 0)
q = 1;
/* The coef functions assume the EMAC unit is in fractional mode */
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
/* set emac unit for dsp processing, and save old macsr, we're running in

View file

@ -2359,8 +2359,11 @@ static void mp3_set_elapsed(struct mp3entry* id3)
}
}
else
{
/* constant bitrate, use exact calculation */
id3->elapsed = id3->offset / (id3->bitrate / 8);
if (id3->bitrate != 0)
id3->elapsed = id3->offset / (id3->bitrate / 8);
}
}
/* Copied from mpeg.c. Should be moved somewhere else. */

View file

@ -118,6 +118,9 @@ static bool mp3headerinfo(struct mp3info *info, unsigned long header)
int bitindex, freqindex;
/* MPEG Audio Version */
if ((header & VERSION_MASK) >> 19 >= sizeof(version_table))
return false;
info->version = version_table[(header & VERSION_MASK) >> 19];
if (info->version < 0)
return false;
@ -359,6 +362,14 @@ int get_mp3file_info(int fd, struct mp3info *info)
return -2;
/* OK, we have found a frame. Let's see if it has a Xing header */
if (info->frame_size-4 >= sizeof(frame))
{
#if defined(DEBUG) || defined(SIMULATOR)
DEBUGF("Error: Invalid id3 header, frame_size: %d\n", info->frame_size);
#endif
return -8;
}
if(read(fd, frame, info->frame_size-4) < 0)
return -3;