Skip to content

Potential memory leak (kms.c, memcpy())? #15

@dbstf

Description

@dbstf

When compiling with compiler warnings turned on, I get the following warning:

gcc -o ../lib/libkms.so ../build/libkms-l.o ../build/vlmcs-l.o ../build/crypto-l.o ../build/kms-l.o ../build/endian-l.o ../build/output-l.o ../build/shared_globals-l.o ../build/helpers-l.o ../build/network-l.o ../build/rpc-l.o ../build/crypto_internal-l.o -fPIC  -DVLMCSD_COMPILER=\"gcc\" -DVLMCSD_PLATFORM=\"x86_64-linux-gnu\" -DCONFIG=\"config.h\" -DBUILD_TIME=1758029201 -g -Os -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -pipe -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants -flto "-Wall" -D_CRYPTO_INTERNAL -O2 -g -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIC -Wformat -Wformat-security -Wall -Wextra -Werror=format-security -Werror=implicit-function-declaration -Wl,-z,norelro -Wl,--gc-sections -s -pie -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -lpthread -fvisibility=hidden -shared -DIS_LIBRARY=1 -DSIMPLE_SOCKETS -DNO_TIMEOUT -DNO_SIGHUP -DNO_CL_PIDS -DNO_LOG -DNO_RANDOM_EPID -DNO_INI_FILE -DNO_HELP -DNO_CUSTOM_INTERVALS -DNO_PID_FILE -DNO_USER_SWITCH -DNO_VERBOSE_LOG -DNO_LIMIT -DNO_VERSION_INFORMATION -DNO_PRIVATE_IP_DETECT -DNO_STRICT_MODES -DNO_CLIENT_LIST -DNO_TAP -UNO_SOCKETS -USIMPLE_RPC -UNO_SOCKETS -UUSE_MSRPC
kms.c: In function ‘CreateResponseV6’:
kms.c:823:9: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
  823 |         memcpy(responseEnd - sizeof(((RESPONSE_V6*)0)->HMAC), hash + halfHashSize, halfHashSize);
      |         ^
kms.h:129:14: note: at offset [132, 4294967427] into destination object ‘IV’ of size 16
  129 |         BYTE IV[16];
      |              ^

The program compiles and seems to work correctly as far as I can tell. However, is this a potential memory leak and should be investigated/fixed? Or an incorrect compiler warning?

Metadata

Metadata

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentationquestionFurther information is requested

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions