open(efi_dev_name, O_WRONLY | O_RDWR)

Colin Ian King colin.king at canonical.com
Fri Nov 27 18:51:41 UTC 2020


On 27/11/2020 18:12, Heinrich Schuchardt wrote:
> 
> This code looks fishy:
> 
> /*
>  *  fwts_lib_efi_runtime_open()
>  *      open the device
>  */
> int fwts_lib_efi_runtime_open(void)
> {
>         if (!efi_dev_name)
>                 return -1;
> 
>         return open(efi_dev_name, O_WRONLY | O_RDWR);
> }
> 
> You should either specify O_WRONLY or O_RDWR but not both.
> 
> The current code works by chance because Linux currently happens to
> define O_RDWR := O_RDONLY | O_WRONLY.
> 
> I think this should be changed to
> 
>         return open(efi_dev_name,O_RDWR);
> 
> Best regards
> 
> Heinrich

Yep, good catch, thanks for finding and reporting that. I'll send a fix
to the mailing list for this.

Kind regards,

Colin



More information about the fwts-devel mailing list