Skip to content

Commit

Permalink
json: use secure un{base64,hex}mem for sensitive variants
Browse files Browse the repository at this point in the history
While tracing a LUKS code path in homework, I've noticed that we don't
erase buffers when doing unbase64 or unhex on JSON variants, even if the
variant is marked as sensitive.

(cherry picked from commit 80313c5)
(cherry picked from commit cce7df4)
(cherry picked from commit 2dee004)
  • Loading branch information
kszczek authored and bluca committed Jun 25, 2024
1 parent 5be1c3c commit d5a7b54
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/shared/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -4874,14 +4874,14 @@ int json_variant_unbase64(JsonVariant *v, void **ret, size_t *ret_size) {
if (!json_variant_is_string(v))
return -EINVAL;

return unbase64mem(json_variant_string(v), SIZE_MAX, ret, ret_size);
return unbase64mem_full(json_variant_string(v), SIZE_MAX, /* secure= */ json_variant_is_sensitive(v), ret, ret_size);
}

int json_variant_unhex(JsonVariant *v, void **ret, size_t *ret_size) {
if (!json_variant_is_string(v))
return -EINVAL;

return unhexmem(json_variant_string(v), SIZE_MAX, ret, ret_size);
return unhexmem_full(json_variant_string(v), SIZE_MAX, /* secure= */ json_variant_is_sensitive(v), ret, ret_size);
}

static const char* const json_variant_type_table[_JSON_VARIANT_TYPE_MAX] = {
Expand Down

0 comments on commit d5a7b54

Please sign in to comment.