open(efi_dev_name, O_WRONLY | O_RDWR)

Heinrich Schuchardt xypron.glpk at gmx.de
Fri Nov 27 18:12:37 UTC 2020


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



More information about the fwts-devel mailing list