mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Fix some warnings found during static analysis.
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
#ifndef _CRYPTSETUP_LUKS2_ONDISK_H
|
||||
#define _CRYPTSETUP_LUKS2_ONDISK_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "libcryptsetup.h"
|
||||
|
||||
#define LUKS2_MAGIC_1ST "LUKS\xba\xbe"
|
||||
#define LUKS2_MAGIC_2ND "SKUL\xba\xbe"
|
||||
|
||||
@@ -186,7 +186,7 @@ int LUKS2_generate_hdr(
|
||||
else {
|
||||
//FIXME
|
||||
//offset = size_round_up(areas[7].offset + areas[7].length, alignPayload * SECTOR_SIZE);
|
||||
offset = size_round_up(LUKS2_HDR_DEFAULT_LEN, alignPayload * sector_size);
|
||||
offset = size_round_up(LUKS2_HDR_DEFAULT_LEN, (size_t)alignPayload * sector_size);
|
||||
offset += alignOffset;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ json_object *LUKS2_get_keyslot_jobj(struct luks2_hdr *hdr, int keyslot)
|
||||
json_object *jobj1, *jobj2;
|
||||
char keyslot_name[16];
|
||||
|
||||
if (!hdr)
|
||||
if (!hdr || keyslot < 0)
|
||||
return NULL;
|
||||
|
||||
if (snprintf(keyslot_name, sizeof(keyslot_name), "%u", keyslot) < 1)
|
||||
@@ -125,7 +125,7 @@ json_object *LUKS2_get_token_jobj(struct luks2_hdr *hdr, int token)
|
||||
json_object *jobj1, *jobj2;
|
||||
char token_name[16];
|
||||
|
||||
if (!hdr)
|
||||
if (!hdr || token < 0)
|
||||
return NULL;
|
||||
|
||||
if (snprintf(token_name, sizeof(token_name), "%u", token) < 1)
|
||||
@@ -143,7 +143,7 @@ json_object *LUKS2_get_digest_jobj(struct luks2_hdr *hdr, int digest)
|
||||
json_object *jobj1, *jobj2;
|
||||
char digest_name[16];
|
||||
|
||||
if (!hdr)
|
||||
if (!hdr || digest < 0)
|
||||
return NULL;
|
||||
|
||||
if (snprintf(digest_name, sizeof(digest_name), "%u", digest) < 1)
|
||||
@@ -161,7 +161,7 @@ json_object *LUKS2_get_segment_jobj(struct luks2_hdr *hdr, int segment)
|
||||
json_object *jobj1, *jobj2;
|
||||
char segment_name[16];
|
||||
|
||||
if (!hdr)
|
||||
if (!hdr || segment < 0)
|
||||
return NULL;
|
||||
|
||||
if (snprintf(segment_name, sizeof(segment_name), "%u", segment) < 1)
|
||||
@@ -193,7 +193,7 @@ static json_bool json_str_to_uint64(json_object *jobj, uint64_t *value)
|
||||
|
||||
errno = 0;
|
||||
tmp = strtoull(json_object_get_string(jobj), &endptr, 10);
|
||||
if (*endptr || errno || tmp > UINT64_MAX) {
|
||||
if (*endptr || errno) {
|
||||
log_dbg("Failed to parse uint64_t type from string %s.",
|
||||
json_object_get_string(jobj));
|
||||
*value = 0;
|
||||
|
||||
@@ -306,7 +306,7 @@ int LUKS2_keyslot_open(struct crypt_device *cd,
|
||||
password, password_len, segment, vk);
|
||||
if (r_prio >= 0)
|
||||
r = r_prio;
|
||||
else if (r_prio < 0 && (r_prio != -EPERM) && (r_prio != -ENOENT))
|
||||
else if (r_prio != -EPERM && r_prio != -ENOENT)
|
||||
r = r_prio;
|
||||
else
|
||||
r = LUKS2_keyslot_open_priority(cd, hdr, CRYPT_SLOT_PRIORITY_NORMAL,
|
||||
|
||||
Reference in New Issue
Block a user