Headline
CVE-2023-23205: Memory leaks in multi_client_server.c:213 · Issue #132 · mz-automation/lib60870
An issue was discovered in lib60870 v2.3.2. There is a memory leak in lib60870/lib60870-C/examples/multi_client_server/multi_client_server.c.
Hello, there is a memory leak in lib60870/lib60870-C/examples/multi_client_server/multi_client_server.c:213.
In the directory lib60870/lib60870-C/examples/multi_client_server,this pointer newAsdu in multi_client_server.c:213 is not freed in the end. It will cause memory leaks.
steps to reproduce:
I used gcc 9.4 and AddressSanitizer (export CFLAGS="-g -fsanitize=address" LDFLAGS="-fsanitize=address" before make) to build lib60870/lib60870-C/examples/multi_client_server.
Run this program multi_client_server.
Press the button Ctrl+C to terminate the program multi_client_server.
ASAN Output
$ ./multi_client_server
^C
=================================================================
==11375==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 296 byte(s) in 1 object(s) allocated from:
#0 0x7fa9a372d808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
#1 0x55956bd32773 in Memory_malloc src/hal/memory/lib_memory.c:33
#2 0x55956bd25f59 in CS101_ASDU_create src/iec60870/cs101/cs101_asdu.c:90
#3 0x55956bd1a052 in main /home/saltf1sh/target/lib60870/lib60870-C/examples/multi_client_server/multi_client_server.c:213
#4 0x7fa9a342f0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b2)
SUMMARY: AddressSanitizer: 296 byte(s) leaked in 1 allocation(s).