Fix some coverity scan issues.

The read in kernel crypto backend is part of user crypto API
encryption call, we have to trust it here.

JSON fix is just one place where return code was not checked
for this particular function.
This commit is contained in:
Milan Broz
2023-11-28 10:01:40 +01:00
parent b3f1f611cd
commit c0dfd1178d
2 changed files with 8 additions and 2 deletions

View File

@@ -109,6 +109,7 @@ int crypt_cipher_init_kernel(struct crypt_cipher_kernel *ctx, const char *name,
}
/* The in/out should be aligned to page boundary */
/* coverity[ -taint_source : arg-3 ] */
static int _crypt_cipher_crypt(struct crypt_cipher_kernel *ctx,
const char *in, size_t in_length,
char *out, size_t out_length,

View File

@@ -172,8 +172,13 @@ static int PBKDF2_digest_store(struct crypt_device *cd,
json_object_object_add(jobj_digest, "digest", json_object_new_string(base64_str));
free(base64_str);
if (jobj_digests)
json_object_object_add_by_uint(jobj_digests, digest, jobj_digest);
if (jobj_digests) {
r = json_object_object_add_by_uint(jobj_digests, digest, jobj_digest);
if (r < 0) {
json_object_put(jobj_digest);
return r;
}
}
JSON_DBG(cd, jobj_digest, "Digest JSON:");
return 0;