Subject: | heap-buffer-overflow with RSA_generate_key with valid callback and userdata |
perl5.19.6d-nt-asan (address-sanitizer, DEBUGGING, not threaded) reported the following heap-buffer-overflow
# Testing Net::SSLeay 1.55, Perl 5.019006, /usr/local/bin/perl5.19.6d-nt-asan
# OpenSSL version: 'OpenSSL 1.0.1e 11 Feb 2013'
# OpenSSL platform: 'platform: debian-amd64'
t/local/31_rsa_generate_key.t .......... 1/14
==7114==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x622000019688 at pc 0x7f56b1bde73a bp 0x7fff0f2fb2f0 sp 0x7fff0f2fb2e8
WRITE of size 8 at 0x622000019688 thread T0
#0 0x7f56b1bde739 in ssleay_RSA_generate_key_cb_invoke /home/rurban/.cpan/build/Net-SSLeay-1.55-098c6e/SSLeay.xs:994
#1 0x7f56b15dc7d6 in BN_GENCB_call ??:?
#2 0x7f56b15dd1b0 in BN_generate_prime_ex ??:?
#3 0x7f56b1605b59 in RSA_generate_key_ex ??:?
#4 0x7f56b1608f15 in RSA_generate_key ??:?
#5 0x7f56b1c55f3d in XS_Net__SSLeay_RSA_generate_key /home/rurban/.cpan/build/Net-SSLeay-1.55-098c6e/SSLeay.xs:4255
#6 0x7f56b6297919 in Perl_pp_entersub /home/rurban/Perl/src/build-5.19.6d-nt-asan/pp_hot.c:2760
#7 0x7f56b5fcf64b in Perl_runops_debug /home/rurban/Perl/src/build-5.19.6d-nt-asan/dump.c:2270
#8 0x7f56b59dea00 in S_run_body /home/rurban/Perl/src/build-5.19.6d-nt-asan/perl.c:2428
#9 0x7f56b59dab59 in perl_run /home/rurban/Perl/src/build-5.19.6d-nt-asan/perl.c:2349
#10 0x42c2c7 in main /home/rurban/Perl/src/build-5.19.6d-nt-asan/perlmain.c:112
#11 0x7f56b4860994 in __libc_start_main /home/aurel32/eglibc/eglibc-2.17/csu/libc-start.c:276
#12 0x42bc6c in _start ??:?
0x622000019688 is located 0 bytes to the right of 5512-byte region [0x622000018100,0x622000019688)
==7114==AddressSanitizer CHECK failed: /tmp/buildd/llvm-toolchain-3.3-3.3/projects/compiler-rt/lib/asan/asan_allocator2.cc:218 "((id)) != (0)" (0x0, 0x0)
#0 0x42301f in _ZN6__asanL15AsanCheckFailedEPKciS1_yy asan_rtl.o:?
#1 0x4247f1 in _ZN11__sanitizer11CheckFailedEPKciS1_yy ??:?
#2 0x40e5d1 in _ZN6__asan13AsanChunkView13GetAllocStackEPN11__sanitizer10StackTraceE ??:?
#3 0x420286 in _ZN6__asan19DescribeHeapAddressEmm ??:?
#4 0x4212f2 in __asan_report_error ??:?
#5 0x422509 in __asan_report_store8 ??:?
#6 0x7f56b1bde739 in ssleay_RSA_generate_key_cb_invoke /home/rurban/.cpan/build/Net-SSLeay-1.55-098c6e/SSLeay.xs:994
#7 0x7f56b15dc7d6 in BN_GENCB_call ??:?
#8 0x7f56b15dd1b0 in BN_generate_prime_ex ??:?
#9 0x7f56b1605b59 in RSA_generate_key_ex ??:?
#10 0x7f56b1608f15 in RSA_generate_key ??:?
#11 0x7f56b1c55f3d in XS_Net__SSLeay_RSA_generate_key /home/rurban/.cpan/build/Net-SSLeay-1.55-098c6e/SSLeay.xs:4255
#12 0x7f56b6297919 in Perl_pp_entersub /home/rurban/Perl/src/build-5.19.6d-nt-asan/pp_hot.c:2760
#13 0x7f56b5fcf64b in Perl_runops_debug /home/rurban/Perl/src/build-5.19.6d-nt-asan/dump.c:2270
#14 0x7f56b59dea00 in S_run_body /home/rurban/Perl/src/build-5.19.6d-nt-asan/perl.c:2428
#15 0x7f56b59dab59 in perl_run /home/rurban/Perl/src/build-5.19.6d-nt-asan/perl.c:2349
#16 0x42c2c7 in main /home/rurban/Perl/src/build-5.19.6d-nt-asan/perlmain.c:112
#17 0x7f56b4860994 in __libc_start_main /home/aurel32/eglibc/eglibc-2.17/csu/libc-start.c:276
#18 0x42bc6c in _start ??:?
Failed 2/14 subtests
on test 13
RSA_generate_key with valid callback and userdata
The error is rarely reproducible.