Bus error on Composer install

9. novembris, 2024

I installed php 7.4 on Alpine Linux versions 3.20 and 3.19. Php works fine but there is problem with Composer. When I tried to install Composer itself it gave me error “Bus error”. Tried to debug Composer installer file and found that Bus error message is thrown by this function call openssl_x509_parse($contents)

PHP
composer-installer.php
function validateCaFile($contents)
{
    // assume the CA is valid if php is vulnerable to
    // https://www.sektioneins.de/advisories/advisory-012013-php-openssl_x509_parse-memory-corruption-vulnerability.html
    if (
        PHP_VERSION_ID <= 50327
        || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50422)
        || (PHP_VERSION_ID >= 50500 && PHP_VERSION_ID < 50506)
    ) {
        return !empty($contents);
    }

    
    // !! This function is throwing Bus error message
    return (bool) openssl_x509_parse($contents);
}

If you disable TLS with –disable-tls flag then composer installs just fine

PHP
php composer-install.php --disable-tls

But problems is not solved. When you try to install Composer package you are greeted with another error. This time error is Segmentation fault.

What is interesting that on same Alpine linux 3.20 with php 8 everything works fine. So I came to conclusion that php 7.4 openssl is not working properly with OpenSSL version 3.3.2. And that is why Composer is throwing Bus error and Segmentation fault errors.

So what is a solution? Install Alpine linux 3.16. There is Openssl version 1.1.1 and php 7.4 Composer works just fine

Or disable TLS for composer