@@ -701,6 +701,7 @@ extern "C" {
701
701
// Use FreeBSD system-level libefivar
702
702
#include < efivar.h>
703
703
}
704
+ #include < iostream>
704
705
705
706
int qefivar_variables_supported (void )
706
707
{
@@ -718,12 +719,13 @@ static int qefivar_get_variable_size(const QUuid &uuid, const QString &name, siz
718
719
719
720
efi_guid_t guid;
720
721
return_code = efi_str_to_guid (c_uuid, &guid);
721
- if (return_code != 0 )
722
+ if (return_code < 0 )
722
723
{
723
724
return return_code;
724
725
}
726
+ return_code = efi_get_variable_size (guid, c_name, size);
725
727
726
- return efi_get_variable_size (guid, c_name, size) ;
728
+ return 0 ;
727
729
}
728
730
729
731
static int qefivar_get_variable (QUuid &uuid, QString &name, uint8_t **data, size_t *size, uint32_t *attributes)
@@ -737,18 +739,32 @@ static int qefivar_get_variable(QUuid &uuid, QString &name, uint8_t **data, size
737
739
738
740
efi_guid_t guid;
739
741
return_code = efi_str_to_guid (c_uuid, &guid);
740
- if (return_code != 0 )
742
+ if (return_code < 0 )
741
743
{
742
744
return return_code;
743
745
}
744
746
745
747
return_code = efi_get_variable_size (guid, c_name, size);
746
- if (size == 0 || return_code != 0 )
748
+ if (* size == 0 || return_code < 0 )
747
749
{
748
750
return return_code;
749
751
}
750
752
751
- return efi_get_variable (guid, c_name, data, size, attributes);
753
+ uint8_t *temp_data;
754
+ return_code = efi_get_variable (guid, c_name, &temp_data, size, attributes);
755
+ if (*size == 0 || return_code < 0 )
756
+ {
757
+ return return_code;
758
+ }
759
+ // Allocate to have the same behaviour with Linux efivar
760
+ *data = (uint8_t *)malloc (*size);
761
+ std::memcpy (*data, temp_data, *size);
762
+
763
+ if (return_code < 0 )
764
+ {
765
+ return return_code;
766
+ }
767
+ return 0 ;
752
768
}
753
769
754
770
static int qefivar_set_variable (const QUuid &uuid, const QString &name, uint8_t *data,
@@ -763,13 +779,20 @@ static int qefivar_set_variable(const QUuid &uuid, const QString &name, uint8_t
763
779
764
780
efi_guid_t guid;
765
781
return_code = efi_str_to_guid (c_uuid, &guid);
766
- if (return_code != 0 )
782
+ if (return_code < 0 )
767
783
{
768
784
return return_code;
769
785
}
770
786
771
787
// Arg "mode" is not supported here
772
- return efi_set_variable (guid, c_name, data, data_size, attributes);
788
+ return_code = efi_set_variable (guid, c_name, data, data_size, attributes);
789
+
790
+ if (return_code < 0 )
791
+ {
792
+ return return_code;
793
+ }
794
+
795
+ return 0 ;
773
796
}
774
797
775
798
#else
0 commit comments