diff options
author | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-05-02 17:51:01 +0000 |
---|---|---|
committer | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-05-02 17:51:01 +0000 |
commit | aa220d5acdbfd8178580e7eb503c205406e2be74 (patch) | |
tree | 00b576acd86a120c371ab7257787e173d08970c0 /apps/gui/gwps-common.c | |
parent | 2a20bfe15325a2a94f49e0cec49f20b3c2aecc18 (diff) | |
download | rockbox-aa220d5acdbfd8178580e7eb503c205406e2be74.tar.gz rockbox-aa220d5acdbfd8178580e7eb503c205406e2be74.zip |
Trim a bunch of long lines and fix an infinite loop and buffer overrun in the impossible case that a WPS line ends with a litteral string but without a newline char (wps_parser.c:774).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13306 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/gwps-common.c')
-rw-r--r-- | apps/gui/gwps-common.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 14a0d565f4..ddfddc5ec7 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c | |||
@@ -769,8 +769,8 @@ static char *get_token_value(struct gui_wps *gwps, | |||
769 | #if CONFIG_RTC | 769 | #if CONFIG_RTC |
770 | struct tm* tm = NULL; | 770 | struct tm* tm = NULL; |
771 | 771 | ||
772 | /* if the token is an RTC one, update the time and do the necessary checks */ | 772 | /* if the token is an RTC one, update the time |
773 | 773 | and do the necessary checks */ | |
774 | if (token->type >= WPS_TOKENS_RTC_BEGIN | 774 | if (token->type >= WPS_TOKENS_RTC_BEGIN |
775 | && token->type <= WPS_TOKENS_RTC_END) | 775 | && token->type <= WPS_TOKENS_RTC_END) |
776 | { | 776 | { |
@@ -1313,7 +1313,7 @@ static int evaluate_conditional(struct gui_wps *gwps, int cond_index) | |||
1313 | /* intval is now the number of the enum option we want to read, | 1313 | /* intval is now the number of the enum option we want to read, |
1314 | starting from 1. If intval is -1, we check if value is empty. */ | 1314 | starting from 1. If intval is -1, we check if value is empty. */ |
1315 | if (intval == -1) | 1315 | if (intval == -1) |
1316 | intval = value && strlen(value) ? 1 : num_options; | 1316 | intval = (value && *value) ? 1 : num_options; |
1317 | else if (intval > num_options || intval < 1) | 1317 | else if (intval > num_options || intval < 1) |
1318 | intval = num_options; | 1318 | intval = num_options; |
1319 | 1319 | ||
@@ -1543,12 +1543,14 @@ static bool update_curr_subline(struct gui_wps *gwps, int line) | |||
1543 | 1543 | ||
1544 | /* if back where we started after search or | 1544 | /* if back where we started after search or |
1545 | only one subline is defined on the line */ | 1545 | only one subline is defined on the line */ |
1546 | if (((search > 0) && (data->lines[line].curr_subline == search_start)) || | 1546 | if (((search > 0) && |
1547 | (data->lines[line].curr_subline == search_start)) || | ||
1547 | only_one_subline) | 1548 | only_one_subline) |
1548 | { | 1549 | { |
1549 | /* no other subline with a time > 0 exists */ | 1550 | /* no other subline with a time > 0 exists */ |
1550 | data->lines[line].subline_expire_time = (reset_subline ? | 1551 | data->lines[line].subline_expire_time = (reset_subline ? |
1551 | current_tick : data->lines[line].subline_expire_time) + 100 * HZ; | 1552 | current_tick : |
1553 | data->lines[line].subline_expire_time) + 100 * HZ; | ||
1552 | break; | 1554 | break; |
1553 | } | 1555 | } |
1554 | else | 1556 | else |
@@ -1565,7 +1567,7 @@ static bool update_curr_subline(struct gui_wps *gwps, int line) | |||
1565 | new_subline_refresh = true; | 1567 | new_subline_refresh = true; |
1566 | data->lines[line].subline_expire_time = (reset_subline ? | 1568 | data->lines[line].subline_expire_time = (reset_subline ? |
1567 | current_tick : data->lines[line].subline_expire_time) + | 1569 | current_tick : data->lines[line].subline_expire_time) + |
1568 | BASE_SUBLINE_TIME * data->sublines[subline_idx].time_mult; | 1570 | BASE_SUBLINE_TIME*data->sublines[subline_idx].time_mult; |
1569 | break; | 1571 | break; |
1570 | } | 1572 | } |
1571 | } | 1573 | } |
@@ -1820,7 +1822,8 @@ bool gui_wps_refresh(struct gui_wps *gwps, | |||
1820 | /* get current subline for the line */ | 1822 | /* get current subline for the line */ |
1821 | new_subline_refresh = update_curr_subline(gwps, line); | 1823 | new_subline_refresh = update_curr_subline(gwps, line); |
1822 | 1824 | ||
1823 | subline_idx = wps_subline_index(data, line, data->lines[line].curr_subline); | 1825 | subline_idx = wps_subline_index(data, line, |
1826 | data->lines[line].curr_subline); | ||
1824 | flags = data->sublines[subline_idx].line_type; | 1827 | flags = data->sublines[subline_idx].line_type; |
1825 | 1828 | ||
1826 | if (refresh_mode == WPS_REFRESH_ALL || (flags & refresh_mode) | 1829 | if (refresh_mode == WPS_REFRESH_ALL || (flags & refresh_mode) |