Check exit value for snprintf where it makes sense.

This commit is contained in:
Milan Broz
2021-05-18 21:41:42 +02:00
parent 413b484774
commit 4cdd826282
17 changed files with 104 additions and 42 deletions

View File

@@ -114,8 +114,12 @@ void keyring_dump(struct crypt_device *cd, const char *json)
int LUKS2_token_keyring_json(char *buffer, size_t buffer_size,
const struct crypt_token_params_luks2_keyring *keyring_params)
{
snprintf(buffer, buffer_size, "{ \"type\": \"%s\", \"keyslots\":[],\"key_description\":\"%s\"}",
int r;
r = snprintf(buffer, buffer_size, "{ \"type\": \"%s\", \"keyslots\":[],\"key_description\":\"%s\"}",
LUKS2_TOKEN_KEYRING, keyring_params->key_description);
if (r < 0 || (size_t)r >= buffer_size)
return -EINVAL;
return 0;
}