summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/dsp.c5
-rw-r--r--apps/playback.c5
-rw-r--r--firmware/mp3data.c11
3 files changed, 19 insertions, 2 deletions
diff --git a/apps/dsp.c b/apps/dsp.c
index 9cdc715109..29e103afb7 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -629,7 +629,10 @@ void dsp_set_eq_coefs(int band)
629 cutoff = 0xffffffff / NATIVE_FREQUENCY * (*setting++); 629 cutoff = 0xffffffff / NATIVE_FREQUENCY * (*setting++);
630 q = ((*setting++) << 16) / 10; /* 16.16 */ 630 q = ((*setting++) << 16) / 10; /* 16.16 */
631 gain = ((*setting++) << 16) / 10; /* s15.16 */ 631 gain = ((*setting++) << 16) / 10; /* s15.16 */
632 632
633 if (q == 0)
634 q = 1;
635
633 /* The coef functions assume the EMAC unit is in fractional mode */ 636 /* The coef functions assume the EMAC unit is in fractional mode */
634 #if defined(CPU_COLDFIRE) && !defined(SIMULATOR) 637 #if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
635 /* set emac unit for dsp processing, and save old macsr, we're running in 638 /* set emac unit for dsp processing, and save old macsr, we're running in
diff --git a/apps/playback.c b/apps/playback.c
index eab6fd104f..9f8fc5a71b 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -2359,8 +2359,11 @@ static void mp3_set_elapsed(struct mp3entry* id3)
2359 } 2359 }
2360 } 2360 }
2361 else 2361 else
2362 {
2362 /* constant bitrate, use exact calculation */ 2363 /* constant bitrate, use exact calculation */
2363 id3->elapsed = id3->offset / (id3->bitrate / 8); 2364 if (id3->bitrate != 0)
2365 id3->elapsed = id3->offset / (id3->bitrate / 8);
2366 }
2364} 2367}
2365 2368
2366/* Copied from mpeg.c. Should be moved somewhere else. */ 2369/* Copied from mpeg.c. Should be moved somewhere else. */
diff --git a/firmware/mp3data.c b/firmware/mp3data.c
index 52aee11e2a..e3de76765b 100644
--- a/firmware/mp3data.c
+++ b/firmware/mp3data.c
@@ -118,6 +118,9 @@ static bool mp3headerinfo(struct mp3info *info, unsigned long header)
118 int bitindex, freqindex; 118 int bitindex, freqindex;
119 119
120 /* MPEG Audio Version */ 120 /* MPEG Audio Version */
121 if ((header & VERSION_MASK) >> 19 >= sizeof(version_table))
122 return false;
123
121 info->version = version_table[(header & VERSION_MASK) >> 19]; 124 info->version = version_table[(header & VERSION_MASK) >> 19];
122 if (info->version < 0) 125 if (info->version < 0)
123 return false; 126 return false;
@@ -359,6 +362,14 @@ int get_mp3file_info(int fd, struct mp3info *info)
359 return -2; 362 return -2;
360 363
361 /* OK, we have found a frame. Let's see if it has a Xing header */ 364 /* OK, we have found a frame. Let's see if it has a Xing header */
365 if (info->frame_size-4 >= sizeof(frame))
366 {
367#if defined(DEBUG) || defined(SIMULATOR)
368 DEBUGF("Error: Invalid id3 header, frame_size: %d\n", info->frame_size);
369#endif
370 return -8;
371 }
372
362 if(read(fd, frame, info->frame_size-4) < 0) 373 if(read(fd, frame, info->frame_size-4) < 0)
363 return -3; 374 return -3;
364 375