mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-06 00:10:04 +01:00
Add some fixes and workarounds for gcc-11 static analyzer.
Not everything is a real bug (false positive rate is very high here), but the code is actually more readable.
This commit is contained in:
@@ -450,6 +450,8 @@ const char *argon2_error_message(int error_code) {
|
||||
|
||||
size_t argon2_encodedlen(uint32_t t_cost, uint32_t m_cost, uint32_t parallelism,
|
||||
uint32_t saltlen, uint32_t hashlen, argon2_type type) {
|
||||
if (!argon2_type2string(type, 0))
|
||||
return 0;
|
||||
return strlen("$$v=$m=,t=,p=$$") + strlen(argon2_type2string(type, 0)) +
|
||||
numlen(t_cost) + numlen(m_cost) + numlen(parallelism) +
|
||||
b64len(saltlen) + b64len(hashlen) + numlen(ARGON2_VERSION_NUMBER) + 1;
|
||||
|
||||
@@ -2296,8 +2296,13 @@ static int _dm_target_query_verity(struct crypt_device *cd,
|
||||
str = strsep(¶ms, " ");
|
||||
if (!str)
|
||||
goto err;
|
||||
if (!root_hash_sig_key_desc)
|
||||
if (!root_hash_sig_key_desc) {
|
||||
root_hash_sig_key_desc = strdup(str);
|
||||
if (!root_hash_sig_key_desc) {
|
||||
r = -ENOMEM;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
if (vp)
|
||||
vp->flags |= CRYPT_VERITY_ROOT_HASH_SIGNATURE;
|
||||
|
||||
@@ -5095,6 +5095,9 @@ const char *crypt_get_cipher_mode(struct crypt_device *cd)
|
||||
/* INTERNAL only */
|
||||
const char *crypt_get_integrity(struct crypt_device *cd)
|
||||
{
|
||||
if (!cd)
|
||||
return NULL;
|
||||
|
||||
if (isINTEGRITY(cd->type))
|
||||
return cd->u.integrity.params.integrity;
|
||||
|
||||
|
||||
@@ -180,6 +180,9 @@ static int device_ready(struct crypt_device *cd, struct device *device)
|
||||
struct stat st;
|
||||
size_t tmp_size;
|
||||
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
if (device->o_direct) {
|
||||
log_dbg(cd, "Trying to open and read device %s with direct-io.",
|
||||
device_path(device));
|
||||
@@ -235,6 +238,9 @@ static int _open_locked(struct crypt_device *cd, struct device *device, int flag
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
log_dbg(cd, "Opening locked device %s", device_path(device));
|
||||
|
||||
if ((flags & O_ACCMODE) != O_RDONLY && device_locked_readonly(device->lh)) {
|
||||
|
||||
Reference in New Issue
Block a user