summaryrefslogtreecommitdiff
path: root/apps/gui/wps_parser.c
diff options
context:
space:
mode:
authorNicolas Pennequin <nicolas.pennequin@free.fr>2007-11-12 18:43:38 +0000
committerNicolas Pennequin <nicolas.pennequin@free.fr>2007-11-12 18:43:38 +0000
commit8537cbf091634efa57768dccff39049afdf6d288 (patch)
tree91cf0310146af63f02dd900c2f97351390362090 /apps/gui/wps_parser.c
parent87e5b1193cf858e2204970b6cce36eb50fefd934 (diff)
downloadrockbox-8537cbf091634efa57768dccff39049afdf6d288.zip
rockbox-8537cbf091634efa57768dccff39049afdf6d288.tar.gz
rockbox-8537cbf091634efa57768dccff39049afdf6d288.tar.bz2
rockbox-8537cbf091634efa57768dccff39049afdf6d288.tar.xz
Add detection for a previously ignored error case: a conditional token is present but no conditional start token (e.g. "%?C%al|>"). This would cause an inifnite loop in the displaying code. Thanks to markun for making the mistake and reporting it ;)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15598 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/wps_parser.c')
-rw-r--r--apps/gui/wps_parser.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c
index 86bd096..84e1b18 100644
--- a/apps/gui/wps_parser.c
+++ b/apps/gui/wps_parser.c
@@ -961,6 +961,11 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr)
data->tokens[data->num_tokens].type = WPS_TOKEN_CONDITIONAL_END;
if (lastcond[level])
data->tokens[lastcond[level]].value.i = data->num_tokens;
+ else
+ {
+ fail = PARSE_FAIL_COND_SYNTAX_ERROR;
+ break;
+ }
lastcond[level] = 0;
data->num_tokens++;
@@ -979,6 +984,11 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr)
data->tokens[data->num_tokens].type = WPS_TOKEN_CONDITIONAL_OPTION;
if (lastcond[level])
data->tokens[lastcond[level]].value.i = data->num_tokens;
+ else
+ {
+ fail = PARSE_FAIL_COND_SYNTAX_ERROR;
+ break;
+ }
lastcond[level] = data->num_tokens;
numoptions[level]++;
@@ -1085,7 +1095,7 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr)
}
}
- if (level >= 0) /* there are unclosed conditionals */
+ if (!fail && level >= 0) /* there are unclosed conditionals */
fail = PARSE_FAIL_UNCLOSED_COND;
#ifdef DEBUG