diff options
author | kovalev0 <107109684+kovalev0@users.noreply.github.com> | 2023-08-05 00:49:11 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-04 23:49:11 +0200 |
commit | 5a6b445f0ed51b0f06c4f0212f060ab45113b670 (patch) | |
tree | 9d01acedb2410634775d9a35c599ee63d3e772cc /src | |
parent | 32e970390500ae15c33c8cf19f61b4aa3a13d34f (diff) | |
download | VeraCrypt-5a6b445f0ed51b0f06c4f0212f060ab45113b670.tar.gz VeraCrypt-5a6b445f0ed51b0f06c4f0212f060ab45113b670.zip |
fix warnings and UB (#1164)
* Crypto: fix warning mismatched bound
../Crypto/cpu.c:67:32: warning: argument 2 of type 'uint32[4]'
{aka 'unsigned int[4]'} with mismatched bound [-Warray-parameter=]
67 | int CpuId(uint32 input, uint32 output[4])
| ~~~~~~~^~~~~~~~~
In file included from ../Crypto/cpu.c:3:
../Crypto/cpu.h:236:33: note: previously declared as 'uint32 *'
{aka 'unsigned int *'}
236 | int CpuId(uint32 input, uint32 *output);
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
* Core/Unix: fix warning ignoring return value
Unix/CoreUnix.cpp: In member function 'virtual std::shared_ptr<VeraCrypt:\
:VolumeInfo> VeraCrypt::CoreUnix::MountVolume(VeraCrypt::MountOptions&)':
Unix/CoreUnix.cpp:682:55: warning: ignoring return value of
'int chown(const char*, __uid_t, __gid_t)' declared with attribute
'warn_unused_result' [-Wunused-result]
682 | chown (mountPoint.c_str(), GetRealUserId(), GetRealGroupId());
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
* Main/Forms: fix warning cast to pointer from integer of different size
Forms/MainFrame.cpp: In member function 'void VeraCrypt::MainFrame:\
:UpdateVolumeList()':
Forms/MainFrame.cpp:1718:106: warning: cast to pointer from integer of
different size [-Wint-to-pointer-cast]
1718 | Gui->InsertToListCtrl (SlotListCtrl, ++prevItemIndex,
fields, 0, (void *) volume->SlotNumber);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
Forms/MainFrame.cpp:1753:114: warning: cast to pointer from integer of
different size [-Wint-to-pointer-cast]
1753 | Gui->InsertToListCtrl (SlotListCtrl, ++prevItemIndex,
fields, 0, (void *) slotNumber);
| ^~~~~~~~~~~~~~~~~~~
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
* Crypto: fix undefined behavior signed integer overflow
In function 'twofish_set_key':
cc1: warning: iteration 4 invokes undefined behavior
[-Waggressive-loop-optimizations]
../Crypto/Twofish.c:626:23: note: within this loop
626 | for (i = 0; i != 40; i += 2)
| ~~^~~~~
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
---------
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
Co-authored-by: Vasiliy Kovalev <kovalev@altlinux.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/Core/Unix/CoreUnix.cpp | 5 | ||||
-rw-r--r-- | src/Crypto/Twofish.c | 2 | ||||
-rw-r--r-- | src/Crypto/cpu.h | 2 | ||||
-rw-r--r-- | src/Main/Forms/MainFrame.cpp | 4 |
4 files changed, 8 insertions, 5 deletions
diff --git a/src/Core/Unix/CoreUnix.cpp b/src/Core/Unix/CoreUnix.cpp index a2b06f3d..0b248fb9 100644 --- a/src/Core/Unix/CoreUnix.cpp +++ b/src/Core/Unix/CoreUnix.cpp @@ -22,6 +22,9 @@ #include "Driver/Fuse/FuseService.h" #include "Volume/VolumePasswordCache.h" +template<typename T> +inline void ignore_result(const T & /* unused result */) {} + namespace VeraCrypt { #ifdef TC_LINUX @@ -691,7 +694,7 @@ namespace VeraCrypt { try { - chown (mountPoint.c_str(), GetRealUserId(), GetRealGroupId()); + ignore_result(chown (mountPoint.c_str(), GetRealUserId(), GetRealGroupId())); } catch (...) { } } } diff --git a/src/Crypto/Twofish.c b/src/Crypto/Twofish.c index f0906f15..ad93b66f 100644 --- a/src/Crypto/Twofish.c +++ b/src/Crypto/Twofish.c @@ -607,7 +607,7 @@ void twofish_set_key(TwofishInstance *instance, const u4byte in_key[]) byte S8[16]; uint32 S32[4]; } us; - int i; + unsigned int i; const byte* key = (const byte*) in_key; us.S32[0] = RS[0][key[0]] ^ RS[1][key[1]] ^ RS[2][key[2]] ^ RS[3][key[3]] ^ RS[4][key[4]] ^ RS[5][key[5]] ^ RS[6][key[6]] ^ RS[7][key[7]]; diff --git a/src/Crypto/cpu.h b/src/Crypto/cpu.h index 47e98a25..a9806b92 100644 --- a/src/Crypto/cpu.h +++ b/src/Crypto/cpu.h @@ -238,7 +238,7 @@ extern volatile int g_isIntel; extern volatile int g_isAMD; extern volatile uint32 g_cacheLineSize; void DetectX86Features(); // must be called at the start of the program/driver -int CpuId(uint32 input, uint32 *output); +int CpuId(uint32 input, uint32 output[4]); // disable all CPU extended features (e.g. SSE, AVX, AES) that may have // been enabled by DetectX86Features. void DisableCPUExtendedFeatures (); diff --git a/src/Main/Forms/MainFrame.cpp b/src/Main/Forms/MainFrame.cpp index 2e34ef85..12389536 100644 --- a/src/Main/Forms/MainFrame.cpp +++ b/src/Main/Forms/MainFrame.cpp @@ -1700,7 +1700,7 @@ namespace VeraCrypt bool slotUpdated = false; if (itemIndex == -1) { - Gui->InsertToListCtrl (SlotListCtrl, ++prevItemIndex, fields, 0, (void *) volume->SlotNumber); + Gui->InsertToListCtrl (SlotListCtrl, ++prevItemIndex, fields, 0, (void *)(intptr_t) volume->SlotNumber); OnListItemInserted (prevItemIndex); listChanged |= true; @@ -1735,7 +1735,7 @@ namespace VeraCrypt { if (itemIndex == -1) { - Gui->InsertToListCtrl (SlotListCtrl, ++prevItemIndex, fields, 0, (void *) slotNumber); + Gui->InsertToListCtrl (SlotListCtrl, ++prevItemIndex, fields, 0, (void *)(intptr_t) slotNumber); OnListItemInserted (prevItemIndex); listChanged |= true; } |