summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2008-10-22 21:35:38 +0000
committerDave Chapman <dave@dchapman.com>2008-10-22 21:35:38 +0000
commita42602b350e3e2d83267371f9fe425ea1583fa6a (patch)
tree53ea2da9200a895d68e0b86b8d894b9ec6795a25 /apps
parent4e14f2d6dd36066f8fa2bdcc20862a139d3d7a9e (diff)
downloadrockbox-a42602b350e3e2d83267371f9fe425ea1583fa6a.tar.gz
rockbox-a42602b350e3e2d83267371f9fe425ea1583fa6a.zip
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')
-rw-r--r--apps/gui/wps_parser.c19
1 files changed, 19 insertions, 0 deletions
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,
870 if (!(ptr = parse_list("sdddd", &set, '|', ptr, &filename, 870 if (!(ptr = parse_list("sdddd", &set, '|', ptr, &filename,
871 &x, &y, &width, &height))) 871 &x, &y, &width, &height)))
872 return WPS_ERROR_INVALID_PARAM; 872 return WPS_ERROR_INVALID_PARAM;
873
873 if (LIST_VALUE_PARSED(set, PB_FILENAME)) /* filename */ 874 if (LIST_VALUE_PARSED(set, PB_FILENAME)) /* filename */
874 bmp_names[PROGRESSBAR_BMP+wps_data->progressbar_count] = filename; 875 bmp_names[PROGRESSBAR_BMP+wps_data->progressbar_count] = filename;
876
875 if (LIST_VALUE_PARSED(set, PB_X)) /* x */ 877 if (LIST_VALUE_PARSED(set, PB_X)) /* x */
876 pb->x = x; 878 pb->x = x;
877 else 879 else
878 pb->x = vp->x; 880 pb->x = vp->x;
881
879 if (LIST_VALUE_PARSED(set, PB_WIDTH)) /* width */ 882 if (LIST_VALUE_PARSED(set, PB_WIDTH)) /* width */
883 {
884 /* A zero width causes a divide-by-zero error later, so reject it */
885 if (width == 0)
886 return WPS_ERROR_INVALID_PARAM;
887
880 pb->width = width; 888 pb->width = width;
889 }
881 else 890 else
882 pb->width = vp->width - pb->x; 891 pb->width = vp->width - pb->x;
892
883 if (LIST_VALUE_PARSED(set, PB_HEIGHT)) /* height, default to font height */ 893 if (LIST_VALUE_PARSED(set, PB_HEIGHT)) /* height, default to font height */
894 {
895 /* A zero height makes no sense - reject it */
896 if (height == 0)
897 return WPS_ERROR_INVALID_PARAM;
898
884 pb->height = height; 899 pb->height = height;
900 }
885 else 901 else
886 pb->height = font_height; 902 pb->height = font_height;
903
887 if (LIST_VALUE_PARSED(set, PB_Y)) /* y */ 904 if (LIST_VALUE_PARSED(set, PB_Y)) /* y */
888 pb->y = y; 905 pb->y = y;
889 else 906 else
890 pb->y = line_y_pos + (font_height-pb->height)/2; 907 pb->y = line_y_pos + (font_height-pb->height)/2;
908
891 wps_data->viewports[wps_data->num_viewports].pb = pb; 909 wps_data->viewports[wps_data->num_viewports].pb = pb;
892 wps_data->progressbar_count++; 910 wps_data->progressbar_count++;
911
893 /* Skip the rest of the line */ 912 /* Skip the rest of the line */
894 return skip_end_of_line(wps_bufptr)-1; 913 return skip_end_of_line(wps_bufptr)-1;
895#else 914#else