Bug 585 - Incorrect zero-length Buffer to String conversion
: Incorrect zero-length Buffer to String conversion
Status: RESOLVED FIXED
: ACPICA
Core/Interpreter
: unspecified
: All Linux
: P3 normal
Assigned To:
:
:
:
:
  Show dependency treegraph
 
Reported: 2007-02-03 05:28 by
Modified: 2008-09-26 19:55 (History)


Attachments
ASL code to reproduce the bug (1.31 KB, text/plain)
2007-02-03 05:29, Fiodor Suietov
Details


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2007-02-03 05:28:55
Neither ToDecimalString and ToHexString reference nor the Buffer to
String conversion rule (Table 17-8 Object Conversion Rules) describes
the result of their use for a zero-length Buffer. Apparently a zero
length string looks like a natural result there.

The attached demo shows that a zero-length Buffer to String conversion
is implemented incorrectly now (the results of conversion differ from
a zero length string).


INTERNAL BUG NUMBER:

   293
------- Comment #1 From 2007-02-03 05:29:44 -------
Created an attachment (id=630) [details]
ASL code to reproduce the bug
------- Comment #2 From 2007-02-03 05:38:58 -------
Possible fix:

+++ exconvrt.c	2007-01-31 15:25:46.573712500 +0300
@@ -638,7 +638,11 @@ AcpiExConvertToString (
          * Create a new string object and string buffer
          * (-1 because of extra separator included in StringLength from above)
          */
-        ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) (StringLength - 
1));
+        if (StringLength)
+        {
+            StringLength--;
+        }
+        ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
         if (!ReturnDesc)
         {
             return_ACPI_STATUS (AE_NO_MEMORY);
@@ -662,7 +666,9 @@ AcpiExConvertToString (
          * Null terminate the string
          * (overwrites final comma/space from above)
          */
-        NewBuf--;
+        if (ObjDesc->Buffer.Length) {
+            NewBuf--;
+        }
         *NewBuf = 0;
         break;
------- Comment #3 From 2007-12-04 13:30:37 -------
Windows doesn't support converting zero-length Buffer
------- Comment #4 From 2008-09-26 19:55:55 -------
ship in ACPICA release 20080926