some clean up. add checks for terminating ')'.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26723 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Teruaki Kawashima 2010-06-09 14:06:42 +00:00
parent 45ed0b86eb
commit bc58b7d984

View file

@ -171,7 +171,7 @@ static int parse_font_load(const char *wps_bufptr,
static int parse_viewportcolour(const char *wps_bufptr,
struct wps_token *token, struct wps_data *wps_data);
static int parse_image_special(const char *wps_bufptr,
struct wps_token *token, struct wps_data *wps_data);
struct wps_token *token, struct wps_data *wps_data);
#endif
#ifdef HAVE_ALBUMART
static int parse_albumart_load(const char *wps_bufptr,
@ -732,6 +732,11 @@ static int parse_image_load(const char *wps_bufptr,
img->num_subimages = atoi(ptr);
if (img->num_subimages <= 0)
return WPS_ERROR_INVALID_PARAM;
/* Check there is a terminating ) */
while(isdigit(*ptr))
ptr++;
if (*ptr != ')')
return WPS_ERROR_INVALID_PARAM;
}
struct skin_token_list *item = new_skin_token_list_item(NULL, img);
if (!item)
@ -762,7 +767,7 @@ static int parse_font_load(const char *wps_bufptr,
if (!(ptr = parse_list("ds", NULL, ',', ptr, &id, &filename)))
return WPS_ERROR_INVALID_PARAM;
/* Check there is a terminating | */
/* Check there is a terminating ) */
if (*ptr != ')')
return WPS_ERROR_INVALID_PARAM;
@ -969,7 +974,6 @@ static int parse_viewport(const char *wps_bufptr,
}
else
return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl7 */
}
else if (*ptr == 'l')
{
@ -1245,7 +1249,7 @@ static int parse_progressbar(const char *wps_bufptr,
PB_X,
PB_Y,
PB_WIDTH,
PB_HEIGHT
PB_HEIGHT,
};
const char *filename;
int x, y, height, width;
@ -1291,14 +1295,7 @@ static int parse_progressbar(const char *wps_bufptr,
if (!(ptr = parse_list("sdddd", &set, ',', ptr, &filename,
&x, &y, &width, &height)))
{
/* If we are in a conditional then we probably don't want to fail
* if the above doesnt work. So assume the | is breaking the conditional
* and move on. The next token will fail if this is incorrect. */
if (level >= 0)
return 0;
return WPS_ERROR_INVALID_PARAM;
}
if (LIST_VALUE_PARSED(set, PB_FILENAME)) /* filename */
pb->bm.data = (char*)filename;
@ -1346,6 +1343,9 @@ static int parse_progressbar(const char *wps_bufptr,
else
pb->y = -line_num - 1; /* Will be computed during the rendering */
if (*ptr != ')')
return WPS_ERROR_INVALID_PARAM;
add_to_ll_chain(&wps_data->progressbars, item);
if (token->type == WPS_TOKEN_VOLUME)
token->type = WPS_TOKEN_VOLUMEBAR;
@ -1421,61 +1421,55 @@ static int parse_albumart_load(const char *wps_bufptr,
if (0 <= albumart_slot)
wps_data->playback_aa_slot = albumart_slot;
if (*ptr == ')')
return skip_end_of_line(wps_bufptr);
else if (*ptr != ',')
return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl7 */
ptr++;
switch (*ptr)
if (*ptr == ',')
{
case 'l':
case 'L':
if (swap_for_rtl)
aa->xalign = WPS_ALBUMART_ALIGN_RIGHT;
else
aa->xalign = WPS_ALBUMART_ALIGN_LEFT;
break;
case 'c':
case 'C':
aa->xalign = WPS_ALBUMART_ALIGN_CENTER;
break;
case 'r':
case 'R':
if (swap_for_rtl)
aa->xalign = WPS_ALBUMART_ALIGN_LEFT;
else
aa->xalign = WPS_ALBUMART_ALIGN_RIGHT;
break;
ptr++;
switch (*ptr)
{
case 'l':
case 'L':
if (swap_for_rtl)
aa->xalign = WPS_ALBUMART_ALIGN_RIGHT;
else
aa->xalign = WPS_ALBUMART_ALIGN_LEFT;
break;
case 'c':
case 'C':
aa->xalign = WPS_ALBUMART_ALIGN_CENTER;
break;
case 'r':
case 'R':
if (swap_for_rtl)
aa->xalign = WPS_ALBUMART_ALIGN_LEFT;
else
aa->xalign = WPS_ALBUMART_ALIGN_RIGHT;
break;
}
ptr++;
}
ptr++;
if (*ptr == ')')
return skip_end_of_line(wps_bufptr);
else if (*ptr != ',')
return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl7 */
ptr++;
switch (*ptr)
if (*ptr == ',')
{
case 't':
case 'T':
aa->yalign = WPS_ALBUMART_ALIGN_TOP;
break;
case 'c':
case 'C':
aa->yalign = WPS_ALBUMART_ALIGN_CENTER;
break;
case 'b':
case 'B':
aa->yalign = WPS_ALBUMART_ALIGN_BOTTOM;
break;
case 'd':
case 'D':
case 'i':
case 'I':
case 's':
case 'S':
/* simply ignored */
break;
ptr++;
switch (*ptr)
{
case 't':
case 'T':
aa->yalign = WPS_ALBUMART_ALIGN_TOP;
break;
case 'c':
case 'C':
aa->yalign = WPS_ALBUMART_ALIGN_CENTER;
break;
case 'b':
case 'B':
aa->yalign = WPS_ALBUMART_ALIGN_BOTTOM;
break;
}
ptr++;
}
if (*ptr != ')')
return WPS_ERROR_INVALID_PARAM;
return skip_end_of_line(wps_bufptr);
}
@ -1554,7 +1548,7 @@ static int parse_touchregion(const char *wps_bufptr,
if (!(ptr = parse_list("dddds", NULL, ',', ptr, &x, &y, &w, &h, &action)))
return WPS_ERROR_INVALID_PARAM;
/* Check there is a terminating | */
/* Check there is a terminating ) */
if (*ptr != ')')
return WPS_ERROR_INVALID_PARAM;