summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2006-04-22 09:02:59 +0000
committerDave Chapman <dave@dchapman.com>2006-04-22 09:02:59 +0000
commit9f34872df065d2a41e9eeefc171afd0323c5b0f4 (patch)
treeb4bc4c0f3adae53e095342d3bc90e7583124d63b
parent65c15eb50b6bfc5254bf8f8455549628100a1117 (diff)
downloadrockbox-9f34872df065d2a41e9eeefc171afd0323c5b0f4.tar.gz
rockbox-9f34872df065d2a41e9eeefc171afd0323c5b0f4.tar.bz2
rockbox-9f34872df065d2a41e9eeefc171afd0323c5b0f4.zip
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
-rw-r--r--apps/gui/gwps-common.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index 41e20ecadd..fe059f4a96 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -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)
{