Fix potential NULL ptr crash if compiled with DMALLOC
PATCH 1/1 Fix potential NULL ptr crash if compiled with DMALLOC
In the unlikely case that we are compiled with -DDMALLOC *and* malloc() returns NULL, there is an uncaught memset() which would crash then. Remove the memset(), as the right the next operation after check_malloc_return() is a mempcy() which will overwrite the whole memory block anyway.
Trac: #586
--- src/openvpn/buffer.c | 1 - 1 file changed, 1 deletion(-)
src/openvpn/buffer.c +0 -1
@@ -706,7 +706,6 @@ string_alloc(const char *str, struct gc_arena *gc)*/ #ifdef DMALLOC ret =openvpn_dmalloc (file, line, n); -memset (ret,0 , n);#else ret =calloc (1 , n);#endif
Signature · 1 line
2.26.2
Hi,
Quoted 19 lines · Gert Doering
In the unlikely case that we are compiled with -DDMALLOC *and*
malloc()returns NULL, there is an uncaughtmemset()which would crash then. Remove thememset(), as the right the next operation aftercheck_malloc_return()is amempcy()which will overwrite the whole memory block anyway.Trac: #586
Signed-off-by Gert Doering <[email protected]...>--- src/openvpn/buffer.c | 1 - 1 file changed, 1 deletion(-)src/openvpn/buffer.c +0
-0
src/openvpn/buffer.c string_alloc(const char *str, struct gc_arena *gc) · line 711
Quoted 7 lines
src/openvpn/buffer.c +0
-1@@ -706,7 +706,6 @@ string_alloc(const char *str, struct gc_arena *gc)*/ #ifdef DMALLOC ret =openvpn_dmalloc (file, line, n); -memset (ret,0 , n);#else ret =calloc (1 , n);#endif
As discussed with Gert on IRC, we could rather add a "if (ret)" before doing memset.
However the DMALLOC code path is barely tested at all and we don't want to introduce more changes than needed.
So for now, we can live with this change.
Signature · 1 line
Antonio Quartulli
Patch has been applied to the master, release/2.5 and release/2.4 branch (crazily important bugfix!).
commit e2acfad40c0d79ce7fd431c380d7466d383bcefa (master) commit acf52dda9f4cb117e9d020dd06fccd7ecb90d303 (release/2.5) commit a7263a125199c6d11710ecf50f9a07424369fdbc (release/2.4)
Author: Gert Doering Date: Fri Apr 2 19:34:14 2021 +0200
Fix potential NULL ptr crash if compiled with DMALLOC
Signed-off-by: Gert Doering <[email protected]...>
Acked-by: Antonio Quartulli <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg21981.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering