提交 ec4b8655 编写于 作者: G Grissiom

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.
上级 1422569e
...@@ -508,10 +508,10 @@ static void token_proc_number(struct finsh_token* self) ...@@ -508,10 +508,10 @@ static void token_proc_number(struct finsh_token* self)
*p = '\0'; *p = '\0';
} }
else else if ( '0' <= ch && ch <= '7' )
{ {
b = 8; b = 8;
while ( is_digit(ch) ) while ( '0' <= ch && ch <= '7' )
{ {
*p++ = ch; *p++ = ch;
ch = token_next_char(self); ch = token_next_char(self);
...@@ -519,6 +519,12 @@ static void token_proc_number(struct finsh_token* self) ...@@ -519,6 +519,12 @@ static void token_proc_number(struct finsh_token* self)
*p = '\0'; *p = '\0';
} }
else
{
/* Not a valid number */
token_prev_char(self);
return;
}
self->value.int_value = token_spec_number(buf, strlen(buf), b); self->value.int_value = token_spec_number(buf, strlen(buf), b);
self->current_token = finsh_token_type_value_int; self->current_token = finsh_token_type_value_int;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册