mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 19:08:26 -06:00
Static Code Analysis: check return of remove function and display message when it fails.
This commit is contained in:
@@ -270,7 +270,8 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
|
|||||||
char tmpstr [1000];
|
char tmpstr [1000];
|
||||||
|
|
||||||
StringCbPrintfA (tmpstr, sizeof(tmpstr), "File not found:\n\n'%s'", szTmpFilePath);
|
StringCbPrintfA (tmpstr, sizeof(tmpstr), "File not found:\n\n'%s'", szTmpFilePath);
|
||||||
remove (outputFile);
|
if (remove (outputFile))
|
||||||
|
StringCbCatA (tmpstr, sizeof(tmpstr), "\nFailed also to delete package file");
|
||||||
PkgError (tmpstr);
|
PkgError (tmpstr);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -287,7 +288,10 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
|
|||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
{
|
{
|
||||||
PkgError ("Cannot allocate memory for uncompressed data");
|
PkgError ("Cannot allocate memory for uncompressed data");
|
||||||
remove (outputFile);
|
if (remove (outputFile))
|
||||||
|
PkgError ("Cannot allocate memory for uncompressed data.\nFailed also to delete package file");
|
||||||
|
else
|
||||||
|
PkgError ("Cannot allocate memory for uncompressed data");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,8 +299,10 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
|
|||||||
// Write the start marker
|
// Write the start marker
|
||||||
if (!SaveBufferToFile (MAG_START_MARKER, outputFile, strlen (MAG_START_MARKER), TRUE))
|
if (!SaveBufferToFile (MAG_START_MARKER, outputFile, strlen (MAG_START_MARKER), TRUE))
|
||||||
{
|
{
|
||||||
|
if (remove (outputFile))
|
||||||
|
PkgError ("Cannot write the start marker\nFailed also to delete package file");
|
||||||
|
else
|
||||||
PkgError ("Cannot write the start marker");
|
PkgError ("Cannot write the start marker");
|
||||||
remove (outputFile);
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +325,8 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
|
|||||||
|
|
||||||
free (tmpBuffer);
|
free (tmpBuffer);
|
||||||
StringCbPrintfA (tmpstr, sizeof(tmpstr), "Cannot load file \n'%s'", szTmpFilePath);
|
StringCbPrintfA (tmpstr, sizeof(tmpstr), "Cannot load file \n'%s'", szTmpFilePath);
|
||||||
remove (outputFile);
|
if (remove (outputFile))
|
||||||
|
StringCbCatA (tmpstr, sizeof(tmpstr), "\nFailed also to delete package file");
|
||||||
PkgError (tmpstr);
|
PkgError (tmpstr);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -352,7 +359,9 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
|
|||||||
mputLong (szTmp32bitPtr, (unsigned __int32) uncompressedDataLen);
|
mputLong (szTmp32bitPtr, (unsigned __int32) uncompressedDataLen);
|
||||||
if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE))
|
if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE))
|
||||||
{
|
{
|
||||||
remove (outputFile);
|
if (remove (outputFile))
|
||||||
|
PkgError ("Cannot write the total size of the uncompressed data.\nFailed also to delete package file");
|
||||||
|
else
|
||||||
PkgError ("Cannot write the total size of the uncompressed data");
|
PkgError ("Cannot write the total size of the uncompressed data");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -362,7 +371,9 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
|
|||||||
compressedBuffer = malloc (uncompressedDataLen + 524288); // + 512K reserve
|
compressedBuffer = malloc (uncompressedDataLen + 524288); // + 512K reserve
|
||||||
if (compressedBuffer == NULL)
|
if (compressedBuffer == NULL)
|
||||||
{
|
{
|
||||||
remove (outputFile);
|
if (remove (outputFile))
|
||||||
|
PkgError ("Cannot allocate memory for compressed data.\nFailed also to delete package file");
|
||||||
|
else
|
||||||
PkgError ("Cannot allocate memory for compressed data");
|
PkgError ("Cannot allocate memory for compressed data");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -370,7 +381,9 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
|
|||||||
compressedDataLen = CompressBuffer (compressedBuffer, buffer, uncompressedDataLen);
|
compressedDataLen = CompressBuffer (compressedBuffer, buffer, uncompressedDataLen);
|
||||||
if (compressedDataLen <= 0)
|
if (compressedDataLen <= 0)
|
||||||
{
|
{
|
||||||
remove (outputFile);
|
if (remove (outputFile))
|
||||||
|
PkgError ("Failed to compress the data.\nFailed also to delete package file");
|
||||||
|
else
|
||||||
PkgError ("Failed to compress the data");
|
PkgError ("Failed to compress the data");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -383,7 +396,9 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
|
|||||||
mputLong (szTmp32bitPtr, (unsigned __int32) compressedDataLen);
|
mputLong (szTmp32bitPtr, (unsigned __int32) compressedDataLen);
|
||||||
if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE))
|
if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE))
|
||||||
{
|
{
|
||||||
remove (outputFile);
|
if (remove (outputFile))
|
||||||
|
PkgError ("Cannot write the total size of the compressed data.\nFailed also to delete package file");
|
||||||
|
else
|
||||||
PkgError ("Cannot write the total size of the compressed data");
|
PkgError ("Cannot write the total size of the compressed data");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -391,7 +406,9 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
|
|||||||
// Write the compressed data
|
// Write the compressed data
|
||||||
if (!SaveBufferToFile (compressedBuffer, outputFile, compressedDataLen, TRUE))
|
if (!SaveBufferToFile (compressedBuffer, outputFile, compressedDataLen, TRUE))
|
||||||
{
|
{
|
||||||
remove (outputFile);
|
if (remove (outputFile))
|
||||||
|
PkgError ("Cannot write compressed data to the package.\nFailed also to delete package file");
|
||||||
|
else
|
||||||
PkgError ("Cannot write compressed data to the package");
|
PkgError ("Cannot write compressed data to the package");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -399,7 +416,9 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
|
|||||||
// Write the end marker
|
// Write the end marker
|
||||||
if (!SaveBufferToFile (MagEndMarker, outputFile, strlen (MagEndMarker), TRUE))
|
if (!SaveBufferToFile (MagEndMarker, outputFile, strlen (MagEndMarker), TRUE))
|
||||||
{
|
{
|
||||||
remove (outputFile);
|
if (remove (outputFile))
|
||||||
|
PkgError ("Cannot write the end marker.\nFailed also to delete package file");
|
||||||
|
else
|
||||||
PkgError ("Cannot write the end marker");
|
PkgError ("Cannot write the end marker");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -417,7 +436,9 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
|
|||||||
if (tmpBuffer == NULL)
|
if (tmpBuffer == NULL)
|
||||||
{
|
{
|
||||||
handleWin32Error (hwndDlg);
|
handleWin32Error (hwndDlg);
|
||||||
remove (outputFile);
|
if (remove (outputFile))
|
||||||
|
PkgError ("Cannot load the package to compute CRC.\nFailed also to delete package file");
|
||||||
|
else
|
||||||
PkgError ("Cannot load the package to compute CRC");
|
PkgError ("Cannot load the package to compute CRC");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -431,7 +452,9 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
|
|||||||
|
|
||||||
if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE))
|
if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE))
|
||||||
{
|
{
|
||||||
remove (outputFile);
|
if (remove (outputFile))
|
||||||
|
PkgError ("Cannot write the total size of the compressed data.\nFailed also to delete package file");
|
||||||
|
else
|
||||||
PkgError ("Cannot write the total size of the compressed data");
|
PkgError ("Cannot write the total size of the compressed data");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user