mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Actually check if a voice file has the correct version before using it
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15629 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
d3d0b26421
commit
f801714572
2 changed files with 10 additions and 7 deletions
15
apps/talk.c
15
apps/talk.c
|
@ -208,7 +208,7 @@ static void load_voicefile(void)
|
|||
|
||||
file_size = filesize(filehandle);
|
||||
if (file_size > audiobufend - audiobuf) /* won't fit? */
|
||||
goto load_err;
|
||||
goto load_err;
|
||||
|
||||
#ifdef HAVE_MMC /* load only the header for now */
|
||||
load_size = offsetof(struct voicefile, index);
|
||||
|
@ -230,9 +230,10 @@ static void load_voicefile(void)
|
|||
{
|
||||
p_voicefile = (struct voicefile*)audiobuf;
|
||||
|
||||
if (p_voicefile->target_id != TARGET_ID)
|
||||
if (p_voicefile->version != VOICE_VERSION ||
|
||||
p_voicefile->target_id != TARGET_ID)
|
||||
{
|
||||
logf("Incompatible voice file (wrong target)");
|
||||
logf("Incompatible voice file");
|
||||
goto load_err;
|
||||
}
|
||||
#if CONFIG_CODEC != SWCODEC
|
||||
|
@ -243,7 +244,7 @@ static void load_voicefile(void)
|
|||
#endif
|
||||
}
|
||||
else
|
||||
goto load_err;
|
||||
goto load_err;
|
||||
|
||||
#ifdef ROCKBOX_LITTLE_ENDIAN
|
||||
for (i = 0; i < p_voicefile->id1_max + p_voicefile->id2_max; i++)
|
||||
|
@ -257,7 +258,7 @@ static void load_voicefile(void)
|
|||
got_size = read(filehandle,
|
||||
(unsigned char *) p_voicefile + offsetof(struct voicefile, index), load_size);
|
||||
if (got_size != load_size) /* read error */
|
||||
goto load_err;
|
||||
goto load_err;
|
||||
#else
|
||||
close(filehandle); /* only the MMC variant leaves it open */
|
||||
filehandle = -1;
|
||||
|
@ -269,7 +270,7 @@ static void load_voicefile(void)
|
|||
return;
|
||||
|
||||
load_err:
|
||||
p_voicefile = NULL;
|
||||
p_voicefile = NULL;
|
||||
has_voicefile = false; /* don't try again */
|
||||
if (filehandle >= 0)
|
||||
{
|
||||
|
@ -555,7 +556,7 @@ void talk_buffer_steal(void)
|
|||
filehandle = -1;
|
||||
}
|
||||
#endif
|
||||
reset_state();;
|
||||
reset_state();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include <stdbool.h>
|
||||
#include "time.h"
|
||||
|
||||
#define VOICE_VERSION 300 /* 3.00 - if you change this, change it in voicefont too */
|
||||
|
||||
enum {
|
||||
/* See array "unit_voiced" in talk.c function "talk_value" */
|
||||
UNIT_INT = 1, /* plain number */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue