diff options
Diffstat (limited to 'sys/contrib/dev/acpica/rsaddr.c')
-rw-r--r-- | sys/contrib/dev/acpica/rsaddr.c | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/sys/contrib/dev/acpica/rsaddr.c b/sys/contrib/dev/acpica/rsaddr.c index 8f3eceb..b6a5e82 100644 --- a/sys/contrib/dev/acpica/rsaddr.c +++ b/sys/contrib/dev/acpica/rsaddr.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsaddr - Address resource descriptors (16/32/64) - * $Revision: 32 $ + * $Revision: 33 $ * ******************************************************************************/ @@ -168,9 +168,12 @@ AcpiRsAddress16Resource ( Buffer += 1; ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - /* Check for the minimum length. */ + /* Validate minimum descriptor length */ + if (Temp16 < 13) - return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + { + return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); + } *BytesConsumed = Temp16 + 3; OutputStruct->Id = ACPI_RSTYPE_ADDRESS16; @@ -279,13 +282,14 @@ AcpiRsAddress16Resource ( /* * This will leave us pointing to the Resource Source Index * If it is present, then save it off and calculate the - * pointer to where the null terminated string goes. + * pointer to where the null terminated string goes: + * Each Interrupt takes 32-bits + the 5 bytes of the + * stream that are default. * - * Note that some buggy resources have a length that indicates the - * Index byte is present even though it isn't (since there is no - * following Resource String.) We add one to catch these. + * Note: Some resource descriptors will have an additional null, so + * we add 1 to the length. */ - if (*BytesConsumed > 16 + 1) + if (*BytesConsumed > (16 + 1)) { /* Dereference the Index */ @@ -492,7 +496,7 @@ AcpiRsAddress16Stream ( /* * Buffer needs to be set to the length of the sting + one for the - * terminating null + * terminating null */ Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address16.ResourceSource.StringPtr) + 1); } @@ -562,11 +566,14 @@ AcpiRsAddress32Resource ( Buffer += 1; ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - /* Check for the minimum length. */ + /* Validate minimum descriptor length */ + if (Temp16 < 23) - return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); - *BytesConsumed = Temp16 + 3; + { + return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); + } + *BytesConsumed = Temp16 + 3; OutputStruct->Id = ACPI_RSTYPE_ADDRESS32; /* @@ -677,13 +684,12 @@ AcpiRsAddress32Resource ( /* * This will leave us pointing to the Resource Source Index * If it is present, then save it off and calculate the - * pointer to where the null terminated string goes. + * pointer to where the null terminated string goes: * - * Note that some buggy resources have a length that indicates the - * Index byte is present even though it isn't (since there is no - * following Resource String.) We add one to catch these. + * Note: Some resource descriptors will have an additional null, so + * we add 1 to the length. */ - if (*BytesConsumed > 26 + 1) + if (*BytesConsumed > (26 + 1)) { /* Dereference the Index */ @@ -722,8 +728,8 @@ AcpiRsAddress32Resource ( /* * In order for the StructSize to fall on a 32-bit boundary, - * calculate the length of the string and expand the - * StructSize to the next 32-bit boundary. + * calculate the length of the string and expand the + * StructSize to the next 32-bit boundary. */ Temp8 = (UINT8) (Index + 1); StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8); @@ -958,11 +964,14 @@ AcpiRsAddress64Resource ( Buffer += 1; ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - /* Check for the minimum length. */ + /* Validate minimum descriptor length */ + if (Temp16 < 43) - return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); - *BytesConsumed = Temp16 + 3; + { + return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); + } + *BytesConsumed = Temp16 + 3; OutputStruct->Id = ACPI_RSTYPE_ADDRESS64; /* @@ -1074,13 +1083,14 @@ AcpiRsAddress64Resource ( /* * This will leave us pointing to the Resource Source Index * If it is present, then save it off and calculate the - * pointer to where the null terminated string goes. + * pointer to where the null terminated string goes: + * Each Interrupt takes 32-bits + the 5 bytes of the + * stream that are default. * - * Note that some buggy resources have a length that indicates the - * Index byte is present even though it isn't (since there is no - * following Resource String.) We add one to catch these. + * Note: Some resource descriptors will have an additional null, so + * we add 1 to the length. */ - if (*BytesConsumed > 46 + 1) + if (*BytesConsumed > (46 + 1)) { /* Dereference the Index */ @@ -1115,7 +1125,6 @@ AcpiRsAddress64Resource ( * Add the terminating null */ *TempPtr = 0x00; - OutputStruct->Data.Address64.ResourceSource.StringLength = Index + 1; /* @@ -1188,7 +1197,6 @@ AcpiRsAddress64Stream ( /* * Set a pointer to the Length field - to be filled in later */ - LengthField = ACPI_CAST_PTR (UINT16, Buffer); Buffer += 2; @@ -1288,7 +1296,7 @@ AcpiRsAddress64Stream ( /* * Buffer needs to be set to the length of the sting + one for the - * terminating null + * terminating null */ Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address64.ResourceSource.StringPtr) + 1); } |