mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-16 13:20:11 +01:00
Fix keyslot validation.
This commit is contained in:
@@ -447,15 +447,15 @@ static int hdr_validate_json_size(json_object *hdr_jobj)
|
|||||||
{
|
{
|
||||||
json_object *jobj, *jobj1;
|
json_object *jobj, *jobj1;
|
||||||
const char *json;
|
const char *json;
|
||||||
size_t json_area_size, json_size;
|
uint64_t json_area_size, json_size;
|
||||||
|
|
||||||
json_object_object_get_ex(hdr_jobj, "config", &jobj);
|
json_object_object_get_ex(hdr_jobj, "config", &jobj);
|
||||||
json_object_object_get_ex(jobj, "json_size", &jobj1);
|
json_object_object_get_ex(jobj, "json_size", &jobj1);
|
||||||
|
|
||||||
json = json_object_to_json_string_ext(hdr_jobj,
|
json = json_object_to_json_string_ext(hdr_jobj,
|
||||||
JSON_C_TO_STRING_PLAIN | JSON_C_TO_STRING_NOSLASHESCAPE);
|
JSON_C_TO_STRING_PLAIN | JSON_C_TO_STRING_NOSLASHESCAPE);
|
||||||
json_area_size = (size_t)json_object_get_uint64(jobj1);
|
json_area_size = json_object_get_uint64(jobj1);
|
||||||
json_size = strlen(json);
|
json_size = (uint64_t)strlen(json);
|
||||||
|
|
||||||
return json_size > json_area_size ? 1 : 0;
|
return json_size > json_area_size ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -594,7 +594,7 @@ int LUKS2_keyslots_validate(json_object *hdr_jobj)
|
|||||||
json_object_object_get_ex(val, "type", &jobj_type);
|
json_object_object_get_ex(val, "type", &jobj_type);
|
||||||
h = LUKS2_keyslot_handler_type(NULL, json_object_get_string(jobj_type));
|
h = LUKS2_keyslot_handler_type(NULL, json_object_get_string(jobj_type));
|
||||||
if (!h)
|
if (!h)
|
||||||
return 0;
|
continue;
|
||||||
if (h->validate && h->validate(NULL, val)) {
|
if (h->validate && h->validate(NULL, val)) {
|
||||||
log_dbg("Keyslot type %s validation failed on keyslot %d.", h->name, keyslot);
|
log_dbg("Keyslot type %s validation failed on keyslot %d.", h->name, keyslot);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|||||||
Reference in New Issue
Block a user