summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2021-10-08 16:27:18 -0500
committerAlex Elder <elder@linaro.org>2021-10-08 17:01:32 -0500
commitde50c02678b2007ce60f71d998f348cbaf4eff24 (patch)
treeea92aa86a4ab04c5af4132b227897ce0fa61602d
parent4937e552615264b12c025e117324cfacfbf977da (diff)
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>
-rw-r--r--parser.c2
-rw-r--r--tests/bad_octal.qmi2
2 files changed, 2 insertions, 2 deletions
diff --git a/parser.c b/parser.c
index a009def..a0f7955 100644
--- a/parser.c
+++ b/parser.c
@@ -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 */
diff --git a/tests/bad_octal.qmi b/tests/bad_octal.qmi
index 10c43be..df3a826 100644
--- a/tests/bad_octal.qmi
+++ b/tests/bad_octal.qmi
@@ -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 {