From 0bb2e05aefc963b0ad1d8ef8b16125c8abec7c1d Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Mon, 24 Mar 2008 18:40:13 +0000 Subject: Stricter syntax checking of the %V tag - pay attention to the return-code from parse_list, and check for the tailing | symbol. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16784 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/wps_parser.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index 0a06944ba7..fe601c8855 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c @@ -26,6 +26,7 @@ #include "gwps.h" #ifndef __PCTOOL__ #include "settings.h" +#include "misc.h" #include "debug.h" #include "plugin.h" @@ -562,28 +563,35 @@ static int parse_viewport(const char *wps_bufptr, #ifdef HAVE_LCD_COLOR if (depth == 16) { - parse_list("dddddcc", '|', ptr, &vp->x, &vp->y, &vp->width, - &vp->height, &vp->font, &vp->fg_pattern,&vp->bg_pattern); + if (!(ptr = parse_list("dddddcc", '|', ptr, &vp->x, &vp->y, &vp->width, + &vp->height, &vp->font, &vp->fg_pattern,&vp->bg_pattern))) + return WPS_ERROR_INVALID_PARAM; } else #endif #if (LCD_DEPTH == 2) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 2) if (depth == 2) { - parse_list("dddddgg", '|', ptr, &vp->x, &vp->y, &vp->width, - &vp->height, &vp->font, &vp->fg_pattern, &vp->bg_pattern); + if (!(ptr = parse_list("dddddgg", '|', ptr, &vp->x, &vp->y, &vp->width, + &vp->height, &vp->font, &vp->fg_pattern, &vp->bg_pattern))) + return WPS_ERROR_INVALID_PARAM; } else #endif #if (LCD_DEPTH == 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 1) if (depth == 1) { - parse_list("ddddd", '|', ptr, &vp->x, &vp->y, &vp->width, &vp->height, - &vp->font); + if (!(ptr = parse_list("ddddd", '|', ptr, &vp->x, &vp->y, &vp->width, + &vp->height, &vp->font))) + return WPS_ERROR_INVALID_PARAM; } else #endif {} + /* Check for trailing | */ + if (*ptr != '|') + return WPS_ERROR_INVALID_PARAM; + /* Default to using the user font if the font was an invalid number */ if ((vp->font != FONT_SYSFIXED) && (vp->font != FONT_UI)) vp->font = FONT_UI; -- cgit