Fix issues found by Coverity scan.

- possible overflow of data offset calculation in wipe and
- dereferencing of pointer in a keyring error path.
This commit is contained in:
Milan Broz
2018-10-14 21:47:11 +02:00
parent 202aeece3c
commit 27eaf46c8a
2 changed files with 3 additions and 2 deletions

View File

@@ -1220,7 +1220,7 @@ int LUKS_wipe_header_areas(struct luks_phdr *hdr,
/* Wipe complete header, keyslots and padding aread with zeroes. */ /* Wipe complete header, keyslots and padding aread with zeroes. */
offset = 0; offset = 0;
length = hdr->payloadOffset * SECTOR_SIZE; length = (uint64_t)hdr->payloadOffset * SECTOR_SIZE;
wipe_block = 1024 * 1024; wipe_block = 1024 * 1024;
/* On detached header or bogus header, wipe at least the first 4k */ /* On detached header or bogus header, wipe at least the first 4k */

View File

@@ -133,7 +133,8 @@ int keyring_get_passphrase(const char *key_desc,
if (ret < 0) { if (ret < 0) {
err = errno; err = errno;
crypt_memzero(buf, len); if (buf)
crypt_memzero(buf, len);
free(buf); free(buf);
return -err; return -err;
} }