[Skiboot] [PATCH V6 21/21] core/pldm: Get file handle and file length
Christophe Lombard
clombard at linux.vnet.ibm.com
Thu Oct 27 20:38:16 AEDT 2022
Le 30/09/2022 à 14:12, Abhishek SIngh Tomar a écrit :
>> + * Retrieve the file handle and file length from the file attribute
>> + * table.
>> + */
>> +static int find_file_handle_by_lid_id(const char *lid_id,
> ...
>> + file_entry = (struct pldm_file_attr_table_entry *)startptr;
>> +
>> + *file_handle = le32_to_cpu(file_entry->file_handle);
>> + startptr += sizeof(uint32_t);
>> +
>> + file_name_length = le16_to_cpu(file_entry->file_name_length);
>> + startptr += sizeof(file_name_length);
>> +
>> + if (!strncmp(startptr, lid_id, strlen(lid_id))) {
>> + startptr += file_name_length;
>> + *file_length = le32_to_cpu(*(uint32_t *)startptr);
>> + break;
>> + }
> In above code we compare string using strncmp with n=strlen(lid_id)
> This issue maybe rare or impossible to generate but
> 1. if in some case lid_id is substring of strtptr
> 2. if strtptr is smaller but comparision concatinate some bytes
> from file_length which make two string equal
> As there is no comparision between strlen(lid_id) and file_name_length
> Adding comparision between two values can be good practice
correct. We should compare the "lid_id" length and file_name_length
Thanks.
> Thanks
> Reviewed-by: Abhishek Singh Tomar <abhishek at linux.ibm.com>
>
More information about the Skiboot
mailing list