Make the get_image_id() function more robust, and catch a parsing error when parsing the %x tags. This prevents Rockbox crashing when presented with an incorrect %x|filename.bmp| WPS line.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9755 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
65c15eb50b
commit
9f34872df0
1 changed files with 9 additions and 4 deletions
|
@ -84,10 +84,11 @@ static char* skip_utf8_bom(char* buf)
|
|||
static int get_image_id(int c)
|
||||
{
|
||||
if(c >= 'a' && c <= 'z')
|
||||
c -= 'a';
|
||||
if(c >= 'A' && c <= 'Z')
|
||||
c = c - 'A' + 26;
|
||||
return c;
|
||||
return c - 'a';
|
||||
else if(c >= 'A' && c <= 'Z')
|
||||
return c - 'A' + 26;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -287,6 +288,10 @@ bool wps_data_preload_tags(struct wps_data *data, char *buf,
|
|||
{
|
||||
/* get filename */
|
||||
pos = strchr(ptr, '|');
|
||||
|
||||
if (pos == NULL)
|
||||
return false;
|
||||
|
||||
if ((pos - ptr) <
|
||||
(int)sizeof(imgname)-ROCKBOX_DIR_LEN-2)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue