diff options
author | Thomas Jarosch <tomj@simonv.com> | 2014-12-20 12:55:20 +0100 |
---|---|---|
committer | Thomas Jarosch <tomj@simonv.com> | 2014-12-20 12:55:20 +0100 |
commit | 2caf8870afd844c1368d21b98b3d1e4c0ee8bf10 (patch) | |
tree | 4e9282bb097c6522af21526ea14f9301616639de | |
parent | 1ff5fd4d6b8d954b4a110c1c97a2e917c9e31055 (diff) | |
download | rockbox-2caf8870afd844c1368d21b98b3d1e4c0ee8bf10.tar.gz rockbox-2caf8870afd844c1368d21b98b3d1e4c0ee8bf10.zip |
text_viewer plugin: Fix two out-of-bounds buffer accesses
Test code:
--------------
int main(void)
{
static unsigned short extra_spaces[] = { 0, 0x3000 };
return sizeof(extra_spaces);
}
--------------
-> returns four instead of two.
cppcheck reported:
[rockbox/apps/plugins/text_viewer/tv_text_processor.c:180]: (error) Array 'break_chars[27]' acces
sed at index 53, which is out of bounds.
[rockbox/apps/plugins/text_viewer/tv_text_processor.c:195]: (error) Array 'extra_spaces[2]' acces
sed at index 3, which is out of bounds.
Change-Id: I66c305cc5c99e59e7c8e0aa9c86cecbe293ff037
-rw-r--r-- | apps/plugins/text_viewer/tv_text_processor.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/apps/plugins/text_viewer/tv_text_processor.c b/apps/plugins/text_viewer/tv_text_processor.c index d027a9a13a..fa644d7725 100644 --- a/apps/plugins/text_viewer/tv_text_processor.c +++ b/apps/plugins/text_viewer/tv_text_processor.c | |||
@@ -175,7 +175,7 @@ static bool tv_is_line_break_char(unsigned short ch) | |||
175 | if (preferences->word_mode == WM_CHOP) | 175 | if (preferences->word_mode == WM_CHOP) |
176 | return false; | 176 | return false; |
177 | 177 | ||
178 | for (i = 0; i < sizeof(break_chars); i++) | 178 | for (i = 0; i < sizeof(break_chars)/sizeof(unsigned short); i++) |
179 | { | 179 | { |
180 | if (break_chars[i] == ch) | 180 | if (break_chars[i] == ch) |
181 | return true; | 181 | return true; |
@@ -190,7 +190,7 @@ static bool tv_isspace(unsigned short ch) | |||
190 | if (ch < 128 && isspace(ch)) | 190 | if (ch < 128 && isspace(ch)) |
191 | return true; | 191 | return true; |
192 | 192 | ||
193 | for (i = 0; i < sizeof(extra_spaces); i++) | 193 | for (i = 0; i < sizeof(extra_spaces)/sizeof(unsigned short); i++) |
194 | { | 194 | { |
195 | if (extra_spaces[i] == ch) | 195 | if (extra_spaces[i] == ch) |
196 | return true; | 196 | return true; |