cryptsetup: Skip tokens with JSON parsing errors
The plugin already continues on parsing errors but the fallback path not. The plugin swallows ENOMEM as well which is too much, though. Continue on JSON parsing errors by mapping them to EUCLEAN in cryptsetup_get_token_as_json and handle that in any call site, not just the TPM fallback path but also others.
This commit is contained in:
@@ -164,6 +164,7 @@ int cryptsetup_get_token_as_json(
|
||||
* -EINVAL → token index out of range or "type" field missing
|
||||
* -ENOENT → token doesn't exist
|
||||
* -EMEDIUMTYPE → "verify_type" specified and doesn't match token's type
|
||||
* -EUCLEAN → token JSON data cannot be parsed
|
||||
*/
|
||||
|
||||
r = sym_crypt_token_json_get(cd, idx, &text);
|
||||
@@ -172,7 +173,7 @@ int cryptsetup_get_token_as_json(
|
||||
|
||||
r = sd_json_parse(text, 0, &v, NULL, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return r == -ENOMEM ? r : -EUCLEAN; /* Report unparseable token data in a single way for callers to skip */
|
||||
|
||||
if (verify_type) {
|
||||
sd_json_variant *w;
|
||||
|
||||
Reference in New Issue
Block a user