]> git.proxmox.com Git - pve-access-control.git/commitdiff
Catch error instead of segfaulting
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 8 Mar 2016 15:17:55 +0000 (16:17 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 9 Mar 2016 13:40:19 +0000 (14:40 +0100)
when trying to parse a certificate subject, Net::SSLeay
will segfault in libcrypto when given 0 as input. Catch
this and die with a meaningful error message instead.

PVE/AccessControl.pm

index db311213f170a3eea679ee3f4627e285e85e3f4d..b42797b40b5bec15a6113a6c2f9afef62b0397af 100644 (file)
@@ -287,8 +287,15 @@ sub read_x509_subject_spice {
 
     # read x509 subject
     my $bio = Net::SSLeay::BIO_new_file($filename, 'r');
 
     # read x509 subject
     my $bio = Net::SSLeay::BIO_new_file($filename, 'r');
+    die "Could not open $filename using OpenSSL\n"
+       if !$bio;
+
     my $x509 = Net::SSLeay::PEM_read_bio_X509($bio);
     Net::SSLeay::BIO_free($bio);
     my $x509 = Net::SSLeay::PEM_read_bio_X509($bio);
     Net::SSLeay::BIO_free($bio);
+
+    die "Could not parse X509 certificate in $filename\n"
+       if !$x509;
+
     my $nameobj = Net::SSLeay::X509_get_subject_name($x509);
     my $subject = Net::SSLeay::X509_NAME_oneline($nameobj);
     Net::SSLeay::X509_free($x509);
     my $nameobj = Net::SSLeay::X509_get_subject_name($x509);
     my $subject = Net::SSLeay::X509_NAME_oneline($nameobj);
     Net::SSLeay::X509_free($x509);