From de50c02678b2007ce60f71d998f348cbaf4eff24 Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Fri, 8 Oct 2021 16:27:18 -0500 Subject: 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 --- parser.c | 2 +- tests/bad_octal.qmi | 2 +- 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 { -- cgit v1.2.3