[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] smbios: Add a --linux argument to apply linux modalias-li
From: |
Daniel Kiper |
Subject: |
Re: [PATCH v2] smbios: Add a --linux argument to apply linux modalias-like filtering |
Date: |
Tue, 3 Mar 2020 18:23:59 +0100 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
On Tue, Mar 03, 2020 at 05:51:55PM +0100, Julian Andres Klode wrote:
> On Tue, Mar 03, 2020 at 05:44:54PM +0100, Daniel Kiper wrote:
> > On Tue, Mar 03, 2020 at 04:06:34PM +0100, Julian Andres Klode wrote:
> > > @@ -261,6 +279,7 @@ grub_cmd_smbios (grub_extcmd_context_t ctxt,
> > >
> > > const grub_uint8_t *structure;
> > > const char *value;
> > > + char *modified_value = NULL;
> > > grub_int32_t option;
> > > grub_int8_t field_type = -1;
> > > grub_uint8_t i;
> > > @@ -334,12 +353,17 @@ grub_cmd_smbios (grub_extcmd_context_t ctxt,
> > > return grub_error (GRUB_ERR_IO,
> > > N_("failed to retrieve the structure field"));
> > >
> > > + if (state[LINUX_OPT].set)
> > > + value = modified_value = linux_string (value);
> > > +
> > > /* Store or print the formatted value. */
> > > if (state[SETTER_OPT].set)
> > > grub_env_set (state[SETTER_OPT].arg, value);
> > > else
> > > grub_printf ("%s\n", value);
> > >
> > > + grub_free(modified_value);
> >
> > I am not sure why we need modified_value if you free it immediately here...
>
> Because `value` is `const char *` that might point to static buffers or
> other buffers, so we need to store this dynamically allocated string
> somewhere else we can free later.
Ahhh... Right, then Reviewed-by: Daniel Kiper <address@hidden>
Daniel