Tim Rühsen
2017-07-21 14:32:03 UTC
Hi,
I am trying to use clang's address sanitizer on libidn2.
It finds the use of uninitialized stack memory in malloca.c/freea()
(latest gnulib sources).
It is this line which causes problems:
if (((int *) p)[-1] == MAGIC_NUMBER)
Is there anything that can/should be done in the code ?
Maybe using clang's __attribute__((no_sanitize("memory"))) (see
https://clang.llvm.org/docs/MemorySanitizer.html#handling-external-code) ?
Or is it even a false positive that should be addressed at llvm/clang ?
The trace is
==685==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x7fcb2c841ba8 in freea
/usr/oms/src/libidn2/unistring/malloca.c:134:11
#1 0x7fcb2c851b44 in mem_iconveha
/usr/oms/src/libidn2/unistring/striconveha.c:253:7
#2 0x7fcb2c854ea2 in u8_conv_from_encoding
/usr/oms/src/libidn2/unistring/uniconv/u8-conv-from-enc.c:98:11
#3 0x7fcb2c855336 in u8_strconv_from_encoding
/usr/oms/src/libidn2/unistring/uniconv/u-strconv-from-enc.h:35:5
#4 0x7fcb2c8557a4 in u8_strconv_from_locale
/usr/oms/src/libidn2/unistring/uniconv/u8-strconv-from-locale.c:37:10
#5 0x7fcb2c82e546 in idn2_register_ul
/usr/oms/src/libidn2/lib/register.c:245:20
#6 0x48f256 in main /usr/oms/src/libidn2/tests/test-register.c:187:13
#7 0x7fcb2b9592b0 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
#8 0x419b79 in _start
(/usr/oms/src/libidn2/tests/test-register+0x419b79)
SUMMARY: MemorySanitizer: use-of-uninitialized-value
/usr/oms/src/libidn2/unistring/malloca.c:134:11 in freea
Exiting
With Best Regards, Tim
I am trying to use clang's address sanitizer on libidn2.
It finds the use of uninitialized stack memory in malloca.c/freea()
(latest gnulib sources).
It is this line which causes problems:
if (((int *) p)[-1] == MAGIC_NUMBER)
Is there anything that can/should be done in the code ?
Maybe using clang's __attribute__((no_sanitize("memory"))) (see
https://clang.llvm.org/docs/MemorySanitizer.html#handling-external-code) ?
Or is it even a false positive that should be addressed at llvm/clang ?
The trace is
==685==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x7fcb2c841ba8 in freea
/usr/oms/src/libidn2/unistring/malloca.c:134:11
#1 0x7fcb2c851b44 in mem_iconveha
/usr/oms/src/libidn2/unistring/striconveha.c:253:7
#2 0x7fcb2c854ea2 in u8_conv_from_encoding
/usr/oms/src/libidn2/unistring/uniconv/u8-conv-from-enc.c:98:11
#3 0x7fcb2c855336 in u8_strconv_from_encoding
/usr/oms/src/libidn2/unistring/uniconv/u-strconv-from-enc.h:35:5
#4 0x7fcb2c8557a4 in u8_strconv_from_locale
/usr/oms/src/libidn2/unistring/uniconv/u8-strconv-from-locale.c:37:10
#5 0x7fcb2c82e546 in idn2_register_ul
/usr/oms/src/libidn2/lib/register.c:245:20
#6 0x48f256 in main /usr/oms/src/libidn2/tests/test-register.c:187:13
#7 0x7fcb2b9592b0 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
#8 0x419b79 in _start
(/usr/oms/src/libidn2/tests/test-register+0x419b79)
SUMMARY: MemorySanitizer: use-of-uninitialized-value
/usr/oms/src/libidn2/unistring/malloca.c:134:11 in freea
Exiting
With Best Regards, Tim