This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- FlexNet Publisher
- :
- FlexNet Publisher Forum
- :
- Out of bound index in C/C++ methods
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Jun 16, 2022
11:10 AM
Out of bound index in C/C++ methods
Hello,
I get the following warning when I compile sample C++ code:
In file included from License.h:15,
from License.cc:10:
License.cc: In static member function ‘static std::string License::_cryptFeature(const string&, size_t*)’:
License.cc:865:5: warning: ‘void* memcpy(void*, const void*, size_t)’ offset 160 is out of the bounds [0, 120] of object ‘lm_prikey’ with type ‘unsigned char [1][3][40]’ [-Warray-bounds]
865 | LM_CODE_GEN_INIT_NEW(&_code, ENCRYPTION_SEED1, ENCRYPTION_SEED2, l_priseedcnt, lm_prikey, lm_prisize);
| ^~~~~~~~~~~~~~~~~~~~
In file included from License.cc:16:
FlexNet/x64_lsb/lmprikey.h:4:22: note: ‘lm_prikey’ declared here
4 | static unsigned char lm_prikey[1][3][40] = {{{0x0, 0x9f, 0x1d, 0xd6, 0x2d, 0xb, 0x3e, 0x75, 0x53, 0xf5, 0x14, 0x5c, 0xd2, 0x86, 0x9c},
| ^~~~~~~~~
A close reading seems to validate this warning, and I suspect an typo in the LM_CODE_GEN_INIT / LM_CODE_GEN_INIT_NEW macros:
for (pcnt = 0; pcnt <= (cnt); pcnt++)
As index starts from zero, the end condition should be pcnt < cnt (rather than pcnt <= cnt).
Do you validate this analysis ?
(0) Replies