[Skiboot] [PATCH V6 15/21] core/pldm: Find lid attribute from bios tables

Frederic Barrat fbarrat at linux.ibm.com
Thu Apr 13 01:33:31 AEST 2023



On 13/09/2022 12:26, Christophe Lombard wrote:
> This specification defines the data structures and messages for
> communicating BIOS settings, BIOS attributes, boot configurations, and
> boot order settings.
> 
> Use the GetBIOSTable command to get STRING, Attribute and Attribute values
> tables from the BIOS.
> 
> The contents of these tables are needed to read/write the desired lid
> files located on the BMC.
> 
> Signed-off-by: Christophe Lombard <clombard at linux.vnet.ibm.com>
> ---
>   core/pldm/pldm-bios-requests.c | 149 +++++++++++++++++++++++++++++++++
>   core/pldm/pldm.h               |   2 +
>   2 files changed, 151 insertions(+)
> 
> diff --git a/core/pldm/pldm-bios-requests.c b/core/pldm/pldm-bios-requests.c
> index 05c3c8db..de03776a 100644
> --- a/core/pldm/pldm-bios-requests.c
> +++ b/core/pldm/pldm-bios-requests.c
> @@ -84,6 +84,155 @@ static void bios_init_complete(bool success)
>   	bios_ready = true;
>   }
>   
> +/*
> + * parse a string, format:
> + * <ATTR_a>=<lid_id_1>,<ATTR_b>=<lid_id_2>
> + */
> +static int find_lid_by_attr_name(char *str, const char *name,
> +				 char **lid)
> +{
> +	const char *pp = "=";
> +	char *attr, *attr_end;
> +	char *p;
> +
> +	for (p = strtok(str, ","); p != NULL; p = strtok(NULL, ",")) {
> +		/* parse now the following string <ATTR>=<lid_id> */
> +		attr = p;
> +		while (*pp != *p)
> +			p++;


We risk an infinite loop in case of a malformed expression. We could 
bound it by the length of p.


> +
> +		attr_end = p;
> +		*attr_end = '\0';
> +
> +		if (!strncmp(attr, name, strlen(name)) &&
> +		    (strlen(attr) == strlen(name))) {
> +			*lid = strdup(++p);
> +			p += strlen(name) + 1;


The above line is useless.

   Fred


More information about the Skiboot mailing list