parser: don't treat 8 as a valid octal digit

The function isodigit() was defined to mimic isxdigit(), indicating
whether a given character was an octal digit.  But as written, it
considers '8' to be a valid octal digit, which it is not.  Fix this
bug.

In addition, the "bad_octal.qmi" test file refers to an undefined
"test_struct" as a message member type.  Fix that by using u32
instead.

Fixes: 61f6fe9 ("parser: be more restrictive when parsing numbers")
Signed-off-by: Alex Elder <elder@linaro.org>
This commit is contained in:
Alex Elder 2021-10-08 16:27:18 -05:00
parent 4937e55261
commit de50c02678
2 changed files with 2 additions and 2 deletions

View File

@ -257,7 +257,7 @@ static struct symbol *qmi_identifier_parse(char *buf, size_t size, char ch)
/* Used for parsing octal numbers */
static int isodigit(int c)
{
return isdigit(c) && c < '9';
return isdigit(c) && c < '8';
}
/* Extract a number from input into the given buffer; return base */

View File

@ -7,7 +7,7 @@ struct qmi_result {
request test_request {
# Note that '8' is not a valid octal digit
optional test_struct foo = 028;
optional u32 foo = 028;
} = 0x23;
response test_response {