Fix various coverity issues.

Mostly INTEGER_OVERFLOW (CWE-190).
This commit is contained in:
Ondrej Kozina
2024-05-02 11:50:45 +02:00
parent 33e26be58b
commit bede116926
8 changed files with 78 additions and 40 deletions

View File

@@ -261,7 +261,7 @@ int crypt_storage_init(struct crypt_storage **ctx,
}
s->sector_size = sector_size;
s->iv_shift = large_iv ? int_log2(sector_size) - SECTOR_SHIFT : 0;
s->iv_shift = large_iv ? (unsigned)int_log2(sector_size) - SECTOR_SHIFT : 0;
*ctx = s;
return 0;

View File

@@ -230,6 +230,7 @@ static size_t utf16_encode_unichar(char16_t *out, char32_t c)
return 1;
case 0x10000U ... 0x10ffffU:
/* coverity[overflow_const:FALSE] */
c -= 0x10000U;
out[0] = htole16((c >> 10) + 0xd800U);
out[1] = htole16((c & 0x3ffU) + 0xdc00U);