mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 00:32:04 +02:00
efi_loader: keep attributes in efi_set_variable_int
Do not change the value of parameter attributes in function efi_set_variable_int(). This allows to use it later. Do not use variable attr for different purposes but declare separate variables (attr and old_attr). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
@@ -827,7 +827,7 @@ efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
|
|||||||
efi_uintn_t old_size;
|
efi_uintn_t old_size;
|
||||||
bool append, delete;
|
bool append, delete;
|
||||||
u64 time = 0;
|
u64 time = 0;
|
||||||
u32 attr;
|
u32 old_attr;
|
||||||
efi_status_t ret = EFI_SUCCESS;
|
efi_status_t ret = EFI_SUCCESS;
|
||||||
|
|
||||||
if (!variable_name || !*variable_name || !vendor ||
|
if (!variable_name || !*variable_name || !vendor ||
|
||||||
@@ -843,8 +843,8 @@ efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
|
|||||||
|
|
||||||
/* check if a variable exists */
|
/* check if a variable exists */
|
||||||
old_size = 0;
|
old_size = 0;
|
||||||
attr = 0;
|
old_attr = 0;
|
||||||
ret = efi_get_variable_int(variable_name, vendor, &attr,
|
ret = efi_get_variable_int(variable_name, vendor, &old_attr,
|
||||||
&old_size, NULL, &time);
|
&old_size, NULL, &time);
|
||||||
append = !!(attributes & EFI_VARIABLE_APPEND_WRITE);
|
append = !!(attributes & EFI_VARIABLE_APPEND_WRITE);
|
||||||
attributes &= ~(u32)EFI_VARIABLE_APPEND_WRITE;
|
attributes &= ~(u32)EFI_VARIABLE_APPEND_WRITE;
|
||||||
@@ -852,15 +852,15 @@ efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
|
|||||||
|
|
||||||
/* check attributes */
|
/* check attributes */
|
||||||
if (old_size) {
|
if (old_size) {
|
||||||
if (ro_check && (attr & EFI_VARIABLE_READ_ONLY)) {
|
if (ro_check && (old_attr & EFI_VARIABLE_READ_ONLY)) {
|
||||||
ret = EFI_WRITE_PROTECTED;
|
ret = EFI_WRITE_PROTECTED;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* attributes won't be changed */
|
/* attributes won't be changed */
|
||||||
if (!delete &&
|
if (!delete &&
|
||||||
((ro_check && attr != attributes) ||
|
((ro_check && old_attr != attributes) ||
|
||||||
(!ro_check && ((attr & ~(u32)EFI_VARIABLE_READ_ONLY)
|
(!ro_check && ((old_attr & ~(u32)EFI_VARIABLE_READ_ONLY)
|
||||||
!= (attributes & ~(u32)EFI_VARIABLE_READ_ONLY))))) {
|
!= (attributes & ~(u32)EFI_VARIABLE_READ_ONLY))))) {
|
||||||
ret = EFI_INVALID_PARAMETER;
|
ret = EFI_INVALID_PARAMETER;
|
||||||
goto err;
|
goto err;
|
||||||
@@ -902,7 +902,7 @@ efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
|
|||||||
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) {
|
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) {
|
||||||
ret = efi_variable_authenticate(variable_name, vendor,
|
ret = efi_variable_authenticate(variable_name, vendor,
|
||||||
&data_size, &data,
|
&data_size, &data,
|
||||||
attributes, &attr,
|
attributes, &old_attr,
|
||||||
&time);
|
&time);
|
||||||
if (ret != EFI_SUCCESS)
|
if (ret != EFI_SUCCESS)
|
||||||
goto err;
|
goto err;
|
||||||
@@ -936,7 +936,7 @@ efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
ret = efi_get_variable_int(variable_name, vendor,
|
ret = efi_get_variable_int(variable_name, vendor,
|
||||||
&attr, &old_size, old_data, NULL);
|
&old_attr, &old_size, old_data, NULL);
|
||||||
if (ret != EFI_SUCCESS)
|
if (ret != EFI_SUCCESS)
|
||||||
goto err;
|
goto err;
|
||||||
} else {
|
} else {
|
||||||
@@ -962,8 +962,8 @@ efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
|
|||||||
EFI_VARIABLE_RUNTIME_ACCESS |
|
EFI_VARIABLE_RUNTIME_ACCESS |
|
||||||
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS);
|
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS);
|
||||||
s += sprintf(s, "{");
|
s += sprintf(s, "{");
|
||||||
while (attributes) {
|
for (u32 attr_rem = attributes; attr_rem;) {
|
||||||
attr = 1 << (ffs(attributes) - 1);
|
u32 attr = 1 << (ffs(attr_rem) - 1);
|
||||||
|
|
||||||
if (attr == EFI_VARIABLE_READ_ONLY) {
|
if (attr == EFI_VARIABLE_READ_ONLY) {
|
||||||
s += sprintf(s, "ro");
|
s += sprintf(s, "ro");
|
||||||
@@ -979,8 +979,8 @@ efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
|
|||||||
s = bin2hex(s, (u8 *)&time, sizeof(time));
|
s = bin2hex(s, (u8 *)&time, sizeof(time));
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes &= ~attr;
|
attr_rem &= ~attr;
|
||||||
if (attributes)
|
if (attr_rem)
|
||||||
s += sprintf(s, ",");
|
s += sprintf(s, ",");
|
||||||
}
|
}
|
||||||
s += sprintf(s, "}");
|
s += sprintf(s, "}");
|
||||||
|
Reference in New Issue
Block a user