Hello,

I would like to report sanitizer-detected violations in binutils 2.45 
(strip-new).

I built strip-new with sanitizers enabled using:

CC=clang
CFLAGS="-O1 -g -fno-omit-frame-pointer 
-fsanitize=address,undefined,integer,bounds"
LDFLAGS="-fsanitize=address,undefined,integer,bounds"

I observed 15 reports at the same source location:

/root/build/binutils-2.45/bfd/cache.c:566:18

All 15 reports have the same violation type. They may correspond to the same 
underlying issue.

One example is:

/root/build/binutils-2.45/bfd/cache.c:566:18: runtime error: implicit 
conversion from type 'int' of value -2097153 (32-bit, signed) to type 'unsigned 
int' changed the value to 4292870143 (32-bit, unsigned)
#0 0x9cf7f6 in _bfd_cache_init_unlocked 
/root/build/binutils-2.45/bfd/cache.c:566:18
#1 0x9cf6de in bfd_cache_init /root/build/binutils-2.45/bfd/cache.c:587:17
#2 0x584a79 in bfd_fopen /root/build/binutils-2.45/bfd/opncls.c:291:8
#3 0x5852ee in bfd_openr /root/build/binutils-2.45/bfd/opncls.c:334:10
#4 0x4cc630 in copy_file /root/build/binutils-2.45/binutils/objcopy.c:3900:10
#5 0x4cb114 in strip_main /root/build/binutils-2.45/binutils/objcopy.c:5109:7
#6 0x4ca8db in main /root/build/binutils-2.45/binutils/objcopy.c:6315:5
#7 0x78b076dddc86 in __libc_start_main 
/build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:310
#8 0x41c2d9 in _start 
(/work/build/binutils-2.45/obj-gcov2/binutils/strip-new+0x41c2d9)

The relevant state variable is:

static unsigned max_open_files = 0;

In bfd/cache.c, bfd_cache_max_open() uses an int local variable (max) and then 
assigns it to the unsigned state variable max_open_files.


Best regards,
Lingfeng Chen

Reply via email to