Subject: | No null pointer check in connect |
Short story: I am getting coredumps. Not sure who is guilty (maybe
some caller, Net::SSLeay itself), but XS_Net__SSLeay_connect gladly
passess null pointer to OpenSSL. Please provide reasonable perl-side
backtrace instead.
Longer story: a few mail and web scrapers I wrote years ago and used
for years started to repeatably crash after some system update. The
C-side backtrace is short, but fairly self-explaining:
(gdb) bt
#0 SSL_connect (s=0x0) at ssl_lib.c:945
#1 0x00007f55448265ca in XS_Net__SSLeay_connect (my_perl=<optimized out>,
cv=<optimized out>) at SSLeay.c:2045
#2 0x00007f554709d866 in Perl_pp_entersub () from /usr/lib/libperl.so.5.18
#3 0x00007f5547095e86 in Perl_runops_standard () from /usr/lib/libperl.so.5.18
#4 0x00007f554702e844 in perl_run () from /usr/lib/libperl.so.5.18
#5 0x0000000000400dd9 in main ()
As one can see, SSL_connect is getting null pointer as parameter (which
should be SSL*). And here is the critical snippet of XS_Net__SSLeay_connect:
SSL * s = INT2PTR(SSL *,SvIV(ST(0)))
;
int RETVAL;
dXSTARG;
RETVAL = SSL_connect(s);
It would be nice if instead of dumping core if XS_Net__SSLeay_connect
happens to get 0 as parameter, this routine (or sth wrapping it) croak-ed
on perl side.