mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-18 17:42:36 -05:00
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:
parent
ea6b4cbe4f
commit
93b6a1d12c
3 changed files with 19 additions and 2 deletions
|
|
@ -629,7 +629,10 @@ void dsp_set_eq_coefs(int band)
|
||||||
cutoff = 0xffffffff / NATIVE_FREQUENCY * (*setting++);
|
cutoff = 0xffffffff / NATIVE_FREQUENCY * (*setting++);
|
||||||
q = ((*setting++) << 16) / 10; /* 16.16 */
|
q = ((*setting++) << 16) / 10; /* 16.16 */
|
||||||
gain = ((*setting++) << 16) / 10; /* s15.16 */
|
gain = ((*setting++) << 16) / 10; /* s15.16 */
|
||||||
|
|
||||||
|
if (q == 0)
|
||||||
|
q = 1;
|
||||||
|
|
||||||
/* The coef functions assume the EMAC unit is in fractional mode */
|
/* The coef functions assume the EMAC unit is in fractional mode */
|
||||||
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
||||||
/* set emac unit for dsp processing, and save old macsr, we're running in
|
/* set emac unit for dsp processing, and save old macsr, we're running in
|
||||||
|
|
|
||||||
|
|
@ -2359,8 +2359,11 @@ static void mp3_set_elapsed(struct mp3entry* id3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
/* constant bitrate, use exact calculation */
|
/* 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. */
|
/* Copied from mpeg.c. Should be moved somewhere else. */
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,9 @@ static bool mp3headerinfo(struct mp3info *info, unsigned long header)
|
||||||
int bitindex, freqindex;
|
int bitindex, freqindex;
|
||||||
|
|
||||||
/* MPEG Audio Version */
|
/* MPEG Audio Version */
|
||||||
|
if ((header & VERSION_MASK) >> 19 >= sizeof(version_table))
|
||||||
|
return false;
|
||||||
|
|
||||||
info->version = version_table[(header & VERSION_MASK) >> 19];
|
info->version = version_table[(header & VERSION_MASK) >> 19];
|
||||||
if (info->version < 0)
|
if (info->version < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -359,6 +362,14 @@ int get_mp3file_info(int fd, struct mp3info *info)
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
/* OK, we have found a frame. Let's see if it has a Xing header */
|
/* 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)
|
if(read(fd, frame, info->frame_size-4) < 0)
|
||||||
return -3;
|
return -3;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue