[PATCH 1/8] acpi: method: add DDN, HID, HRV, PLD, SUB, STR checks

Colin Ian King colin.king at canonical.com
Thu Sep 27 08:48:05 UTC 2012


On 27/09/12 04:18, Alex Hung wrote:
> On 09/25/2012 11:23 AM, IvanHu wrote:
>>
>>> +
>>> +static bool method_valid_HID_string(char *str)
>>> +{
>>> +    if (strlen(str) == 7) {
>>> +        /* PNP ID, must be 3 capitals followed by 4 hex */
>>> +        if (!isupper(str[0]) ||
>>> +            !isupper(str[1]) ||
>>> +            !isupper(str[2])) return false;
>>> +        if (!isxdigit(str[3]) ||
>>> +            !isxdigit(str[4]) ||
>>> +            !isxdigit(str[5]) ||
>>> +            !isxdigit(str[6])) return false;
>>> +        return true;
>>> +    }
>>> +
>>> +    if (strlen(str) == 8) {
>>> +        /* ACPI ID, must be 4 capitals followed by 4 hex */
>>> +        if (!isupper(str[0]) ||
>>> +            !isupper(str[1]) ||
>>> +            !isupper(str[2]) ||
>>> +            !isupper(str[3])) return false;
>>> +        if (!isxdigit(str[4]) ||
>>> +            !isxdigit(str[5]) ||
>>> +            !isxdigit(str[6]) ||
>>> +            !isxdigit(str[7])) return false;
>>> +        return true;
>>> +    }
>>> +
>>> +    return false;
>>> +}
>>> +
>>
>> Just wondering if the ACPI ID for 8 digit shouldn't be valid?
>> For example,
>> Name(_HID, "80860003") // PCI-assigned device identifier
>>
>>
>>
>
> I confirmed ACPI spec as below:
>
> A valid ACPI ID must be of the form "NNNN####" where N is an uppercase
> letter or a digit ('0'-'9') and # is a hex digit.
>
> How about
>
> +    if (strlen(str) == 8) {
> +        /* ACPI ID, must be 4 capitals followed by 4 hex */
> +        if (!isupper(str[0] && !isxdigit(str[0]) ||
> +            !isupper(str[1] && !isxdigit(str[1]) ||
> +            !isupper(str[2] && !isxdigit(str[2]) ||
> +            !isupper(str[3] && !isxdigit(str[3])) return false;
> +        if (!isxdigit(str[4]) ||
> +            !isxdigit(str[5]) ||
> +            !isxdigit(str[6]) ||
> +            !isxdigit(str[7])) return false;
> +        return true;
> +    }
>
>
Section 6.1.5 states:

A valid PNP ID must be of the form "AAA####" where A is an uppercase 
letter and # is a hex digit. A valid ACPI ID must be of the form 
"NNNN####" where N is an uppercase letter or a digit ('0'-'9') and # is 
a hex digit. This specification reserves the string "ACPI" for use only
with devices defined herein. It further reserves all strings 
representing 4 HEX digits for exclusive use with PCI-assigned Vendor IDs.

so I think it should in fact be:

         if (strlen(str) == 8) {
                 if ((!isupper(str[0]) && !isdigit(str[0])) ||
                     (!isupper(str[1]) && !isdigit(str[1])) ||
                     (!isupper(str[2]) && !isdigit(str[2])) ||
                     (!isupper(str[3]) && !isdigit(str[3]))) return false;
                 if (!isxdigit(str[4]) ||
                     !isxdigit(str[5]) ||
                     !isxdigit(str[6]) ||
                     !isxdigit(str[7])) return false;
                 return true;
         }
         return false;





More information about the fwts-devel mailing list