diff options
| author | Grissiom <[email protected]> | 2014-04-12 16:55:00 +0800 |
|---|---|---|
| committer | Grissiom <[email protected]> | 2014-04-12 16:55:00 +0800 |
| commit | ec4b8655794ddda25984159ce14382ed468ca48f (patch) | |
| tree | 16c8efd30b4c6c4687b2f4b845655f5c8d1efe89 /components | |
| parent | 1422569e7cae6d7d6cef64e60ac3afe12b53f617 (diff) | |
finsh: add check on converting octal numbers
The digit in octal numbers should with in 0~7. Check on it in
token_proc_number. This issue is found by Clang.
Diffstat (limited to 'components')
| -rw-r--r-- | components/finsh/finsh_token.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/components/finsh/finsh_token.c b/components/finsh/finsh_token.c index 5ab29ad2aa..3ca21e60db 100644 --- a/components/finsh/finsh_token.c +++ b/components/finsh/finsh_token.c @@ -508,10 +508,10 @@ static void token_proc_number(struct finsh_token* self) *p = '\0'; } - else + else if ( '0' <= ch && ch <= '7' ) { b = 8; - while ( is_digit(ch) ) + while ( '0' <= ch && ch <= '7' ) { *p++ = ch; ch = token_next_char(self); @@ -519,6 +519,12 @@ static void token_proc_number(struct finsh_token* self) *p = '\0'; } + else + { + /* Not a valid number */ + token_prev_char(self); + return; + } self->value.int_value = token_spec_number(buf, strlen(buf), b); self->current_token = finsh_token_type_value_int; |
