From a42602b350e3e2d83267371f9fe425ea1583fa6a Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Wed, 22 Oct 2008 21:35:38 +0000 Subject: Don't accept 0 for the width or height of a progress bar in the %pb tag. A zero width causes a divide by zero, and a zero height simply doesn't make any sense, so we assume it was a mistake. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18863 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/wps_parser.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'apps/gui') diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index fc207efb9b..1b845c9f8a 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c @@ -870,26 +870,45 @@ static int parse_progressbar(const char *wps_bufptr, if (!(ptr = parse_list("sdddd", &set, '|', ptr, &filename, &x, &y, &width, &height))) return WPS_ERROR_INVALID_PARAM; + if (LIST_VALUE_PARSED(set, PB_FILENAME)) /* filename */ bmp_names[PROGRESSBAR_BMP+wps_data->progressbar_count] = filename; + if (LIST_VALUE_PARSED(set, PB_X)) /* x */ pb->x = x; else pb->x = vp->x; + if (LIST_VALUE_PARSED(set, PB_WIDTH)) /* width */ + { + /* A zero width causes a divide-by-zero error later, so reject it */ + if (width == 0) + return WPS_ERROR_INVALID_PARAM; + pb->width = width; + } else pb->width = vp->width - pb->x; + if (LIST_VALUE_PARSED(set, PB_HEIGHT)) /* height, default to font height */ + { + /* A zero height makes no sense - reject it */ + if (height == 0) + return WPS_ERROR_INVALID_PARAM; + pb->height = height; + } else pb->height = font_height; + if (LIST_VALUE_PARSED(set, PB_Y)) /* y */ pb->y = y; else pb->y = line_y_pos + (font_height-pb->height)/2; + wps_data->viewports[wps_data->num_viewports].pb = pb; wps_data->progressbar_count++; + /* Skip the rest of the line */ return skip_end_of_line(wps_bufptr)-1; #else -- cgit v1.2.3