Skip to content

Commit ef3efb4

Browse files
acpibobrafaeljw
authored andcommitted
ACPICA: iASL: Return exceptions for string-to-integer conversions
This allows iASL to generate errors by passing exceptions that may be encountered during string-to-integer conversions. The exceptions point out invalid hex, decimal, and octal integers. ACPICA commit e98b8c0a3d96fdabb167c0ef18a809b32ade3228 Link: acpica/acpica@e98b8c0a Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Erik Kaneda <erik.kaneda@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 18aaa02 commit ef3efb4

2 files changed

Lines changed: 26 additions & 11 deletions

File tree

drivers/acpi/acpica/utstrsuppt.c

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,15 @@ acpi_status acpi_ut_convert_octal_string(char *string, u64 *return_value_ptr)
4545
/* Convert each ASCII byte in the input string */
4646

4747
while (*string) {
48-
49-
/* Character must be ASCII 0-7, otherwise terminate with no error */
50-
48+
/*
49+
* Character must be ASCII 0-7, otherwise:
50+
* 1) Runtime: terminate with no error, per the ACPI spec
51+
* 2) Compiler: return an error
52+
*/
5153
if (!(ACPI_IS_OCTAL_DIGIT(*string))) {
54+
#ifdef ACPI_ASL_COMPILER
55+
status = AE_BAD_OCTAL_CONSTANT;
56+
#endif
5257
break;
5358
}
5459

@@ -94,10 +99,15 @@ acpi_status acpi_ut_convert_decimal_string(char *string, u64 *return_value_ptr)
9499
/* Convert each ASCII byte in the input string */
95100

96101
while (*string) {
97-
98-
/* Character must be ASCII 0-9, otherwise terminate with no error */
99-
102+
/*
103+
* Character must be ASCII 0-9, otherwise:
104+
* 1) Runtime: terminate with no error, per the ACPI spec
105+
* 2) Compiler: return an error
106+
*/
100107
if (!isdigit(*string)) {
108+
#ifdef ACPI_ASL_COMPILER
109+
status = AE_BAD_DECIMAL_CONSTANT;
110+
#endif
101111
break;
102112
}
103113

@@ -143,10 +153,15 @@ acpi_status acpi_ut_convert_hex_string(char *string, u64 *return_value_ptr)
143153
/* Convert each ASCII byte in the input string */
144154

145155
while (*string) {
146-
147-
/* Must be ASCII A-F, a-f, or 0-9, otherwise terminate with no error */
148-
156+
/*
157+
* Character must be ASCII A-F, a-f, or 0-9, otherwise:
158+
* 1) Runtime: terminate with no error, per the ACPI spec
159+
* 2) Compiler: return an error
160+
*/
149161
if (!isxdigit(*string)) {
162+
#ifdef ACPI_ASL_COMPILER
163+
status = AE_BAD_HEX_CONSTANT;
164+
#endif
150165
break;
151166
}
152167

include/acpi/acexcep.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@
4040
struct acpi_exception_info {
4141
char *name;
4242

43-
#ifdef ACPI_HELP_APP
43+
#if defined (ACPI_HELP_APP) || defined (ACPI_ASL_COMPILER)
4444
char *description;
4545
#endif
4646
};
4747

48-
#ifdef ACPI_HELP_APP
48+
#if defined (ACPI_HELP_APP) || defined (ACPI_ASL_COMPILER)
4949
#define EXCEP_TXT(name,description) {name, description}
5050
#else
5151
#define EXCEP_TXT(name,description) {name}

0 commit comments

Comments
 (0)