diff options
| author | Dave Chapman <dave@dchapman.com> | 2008-10-22 21:35:38 +0000 |
|---|---|---|
| committer | Dave Chapman <dave@dchapman.com> | 2008-10-22 21:35:38 +0000 |
| commit | a42602b350e3e2d83267371f9fe425ea1583fa6a (patch) | |
| tree | 53ea2da9200a895d68e0b86b8d894b9ec6795a25 /apps/gui/wps_parser.c | |
| parent | 4e14f2d6dd36066f8fa2bdcc20862a139d3d7a9e (diff) | |
| download | rockbox-a42602b350e3e2d83267371f9fe425ea1583fa6a.zip rockbox-a42602b350e3e2d83267371f9fe425ea1583fa6a.tar.gz rockbox-a42602b350e3e2d83267371f9fe425ea1583fa6a.tar.bz2 rockbox-a42602b350e3e2d83267371f9fe425ea1583fa6a.tar.xz | |
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
Diffstat (limited to 'apps/gui/wps_parser.c')
| -rw-r--r-- | apps/gui/wps_parser.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index fc207ef..1b845c9 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 |