VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/DcsCfg
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2016-09-26 07:42:24 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2016-10-17 18:17:47 +0200
commit224b1cc286122b8aca5002fec31ed0390b299403 (patch)
tree589a728a9a554361df23389350802d8871ec16f3 /DcsCfg
parent5fb01149ef1cecc36b261094b304ff0654bb7ae3 (diff)
downloadVeraCrypt-DCS-224b1cc286122b8aca5002fec31ed0390b299403.tar.gz
VeraCrypt-DCS-224b1cc286122b8aca5002fec31ed0390b299403.zip
Fix various issues reported by Coverity
Diffstat (limited to 'DcsCfg')
-rw-r--r--DcsCfg/DcsCfgCrypt.c26
-rw-r--r--DcsCfg/DcsCfgMain.c4
2 files changed, 22 insertions, 8 deletions
diff --git a/DcsCfg/DcsCfgCrypt.c b/DcsCfg/DcsCfgCrypt.c
index 4dab9bc..d031dcb 100644
--- a/DcsCfg/DcsCfgCrypt.c
+++ b/DcsCfg/DcsCfgCrypt.c
@@ -880,7 +880,13 @@ BlockRangeWipe(
pos = start;
do {
rd = (UINTN)((remains > CRYPT_BUF_SECTORS) ? CRYPT_BUF_SECTORS : remains);
- RandgetBytes(buf, (UINT32)(rd << 9), FALSE);
+
+ if (!RandgetBytes(buf, (UINT32)(rd << 9), FALSE)) {
+ ERR_PRINT(L"No randoms. Wipe stopped.\n");
+ res = EFI_CRC_ERROR;
+ MEM_FREE(buf);
+ return res;
+ }
res = bio->WriteBlocks(bio, bio->Media->MediaId, pos, rd << 9, buf);
if (EFI_ERROR(res)) {
ERR_PRINT(L"Write error: %r\n", res);
@@ -892,6 +898,7 @@ BlockRangeWipe(
OUT_PRINT(L"%lld %lld \r", pos, remains);
} while (remains > 0);
OUT_PRINT(L"\nDone\n", pos, remains);
+ MEM_FREE(buf);
return res;
}
@@ -1077,11 +1084,18 @@ UpdateDcsBoot() {
DevicePath = DevicePathFromHandle(hDisk);
len = GetDevicePathSize(DevicePath);
// res = EfiSetVar(DCS_BOOT_STR, NULL, DevicePath, len, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS);
- FileSave(NULL, DCS_BOOT_STR, DevicePath, len);
- OUT_PRINT(L"Boot:");
- EfiPrintDevicePath(hDisk);
- OUT_PRINT(L"\n");
- }
+ res = FileSave(NULL, DCS_BOOT_STR, DevicePath, len);
+ if (EFI_ERROR(res)) {
+ OUT_PRINT(L" %r\n", res);
+ return;
+ }
+ else
+ {
+ OUT_PRINT(L"Boot:");
+ EfiPrintDevicePath(hDisk);
+ OUT_PRINT(L"\n");
+ }
+ }
OUT_PRINT(L" %r\n", res);
}
diff --git a/DcsCfg/DcsCfgMain.c b/DcsCfg/DcsCfgMain.c
index 5c2ce2b..59ff730 100644
--- a/DcsCfg/DcsCfgMain.c
+++ b/DcsCfg/DcsCfgMain.c
@@ -350,8 +350,8 @@ DcsCfgMain(
res = EFI_BUFFER_TOO_SMALL;
temp = MEM_ALLOC(size);
if (temp == NULL ||
- EFI_ERROR(res = RndGetBytes(temp, size) ||
- EFI_ERROR(res = FileSave(NULL, (CHAR16*)optFile, temp, size)))
+ EFI_ERROR(res = RndGetBytes(temp, size)) ||
+ EFI_ERROR(res = FileSave(NULL, (CHAR16*)optFile, temp, size))
) {
ERR_PRINT(L"Random: %r\n", res);
}