VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DcsCfg/DcsCfgCrypt.c26
-rw-r--r--DcsCfg/DcsCfgMain.c4
-rw-r--r--DcsInt/DcsInt.c18
-rw-r--r--DcsRe/DcsRe.c2
-rw-r--r--Library/DcsCfgLib/GptEdit.c8
-rw-r--r--Library/PasswordLib/PlatformID.c2
6 files changed, 43 insertions, 17 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);
}
diff --git a/DcsInt/DcsInt.c b/DcsInt/DcsInt.c
index 3fe90d6..46398c9 100644
--- a/DcsInt/DcsInt.c
+++ b/DcsInt/DcsInt.c
@@ -826,7 +826,9 @@ OnExit(
retValue = AsciiStrDecimalToUintn(exitStatusStr);
}
- OnExitGetParam(action, "file", NULL, &fileStr);
+ if (!OnExitGetParam(action, "file", NULL, &fileStr)) {
+ fileStr = NULL;
+ }
if (OnExitGetParam(action, "printinfo", NULL, NULL)) {
@@ -863,12 +865,18 @@ OnExit(
EfiCpuHalt();
}
// Try to exec
- res = EfiExec(h, fileStr);
- if (EFI_ERROR(res)) {
- ERR_PRINT(L"\nStart %s - %r\n", fileStr, res);
+ if (fileStr != NULL) {
+ res = EfiExec(h, fileStr);
+ if (EFI_ERROR(res)) {
+ ERR_PRINT(L"\nStart %s - %r\n", fileStr, res);
+ EfiCpuHalt();
+ }
+ }
+ else {
+ ERR_PRINT(L"\nNo EFI execution path specified. Halting!\n");
EfiCpuHalt();
}
- }
+ }
if (fileStr != NULL) {
EfiSetVar(L"DcsExecCmd", NULL, fileStr, (StrLen(fileStr) + 1) * 2, EFI_VARIABLE_BOOTSERVICE_ACCESS);
diff --git a/DcsRe/DcsRe.c b/DcsRe/DcsRe.c
index 7d08d50..5ccb1b2 100644
--- a/DcsRe/DcsRe.c
+++ b/DcsRe/DcsRe.c
@@ -47,7 +47,7 @@ AppendMenu(
item = (PMENU_ITEM)MEM_ALLOC(sizeof(MENU_ITEM));
if (item == NULL) return item;
item->Action = action;
- StrCat(item->Text, text);
+ StrCatS(item->Text, sizeof (item->Text) / sizeof (CHAR16), text);
item->Select = select;
if (menu != NULL) {
menu->Next = item;
diff --git a/Library/DcsCfgLib/GptEdit.c b/Library/DcsCfgLib/GptEdit.c
index 702ce5d..f814975 100644
--- a/Library/DcsCfgLib/GptEdit.c
+++ b/Library/DcsCfgLib/GptEdit.c
@@ -143,7 +143,7 @@ GptCheckEntryArray(
UINT32 Crc;
UINTN Size;
- Size = PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry;
+ Size = (UINTN) PartHeader->NumberOfPartitionEntries * (UINTN) PartHeader->SizeOfPartitionEntry;
Status = gBS->CalculateCrc32(Entrys, Size, &Crc);
if (EFI_ERROR(Status)) {
return EFI_CRC_ERROR;
@@ -162,7 +162,7 @@ GptUpdateCRC(
UINT32 Crc;
UINTN Size;
- Size = PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry;
+ Size = (UINTN) PartHeader->NumberOfPartitionEntries * (UINTN) PartHeader->SizeOfPartitionEntry;
Status = gBS->CalculateCrc32(Entrys, Size, &Crc);
if (EFI_ERROR(Status)) {
return Status;
@@ -489,6 +489,10 @@ DeListSaveToFile() {
}
if (pad > 0) {
res = FileWrite(file, pad512buf, &pad, NULL);
+ if (EFI_ERROR(res)) {
+ ERR_PRINT(L"Write: %r\n", res);
+ goto error;
+ }
}
}
}
diff --git a/Library/PasswordLib/PlatformID.c b/Library/PasswordLib/PlatformID.c
index 351503e..63b2e7d 100644
--- a/Library/PasswordLib/PlatformID.c
+++ b/Library/PasswordLib/PlatformID.c
@@ -236,7 +236,7 @@ PlatformGetAuthDataByType(
continue;
}
*data = buf;
- *len = mark->AuthDataSize * 1024 * 128;
+ *len = ((UINTN) mark->AuthDataSize) * 1024 * 128;
*secRegionHandle = gBIOHandles[gBioIndexAuth];
return EFI_SUCCESS;
}