Libgourou

Issue 36: Segmentation Fault running utils (Ubuntu Jammy)

Reported by liang, Jun 3, 2022

Novice here. I was able to build from source, but am getting a 
segmentation fault. Looks like it's an issue with my version of 
libssl-dev?

Software versions: Ubuntu Jammy, libgourou version : 0.7.1 (direct 
from repo)

Steps to reproduce the problem:

1. Install dependencies
> apt-get install -y build-essential libzip-dev libssl-dev 
libcurl4-gnutls-dev

> apt list | egrep "ssl-dev|zip-dev|curl4-gnutls-dev"
libcurl4-gnutls-dev/now 7.81.0-1ubuntu1.2 amd64 [installed,local]
libssl-dev/now 3.0.2-0ubuntu1.2 amd64 [installed,local]
libzip-dev/now 1.7.3-1ubuntu2 amd64 [installed,local]

2. clone repository + compile
> git clone git://soutade.fr/libgourou.git 
> cd libgourou
> make

3. move compiled lib + utils to /usr/local/, link
> cp libgourou.so         /usr/local/lib
> cp acsmdownloader /usr/local/bin 
> ldconfig
...

4. segmentation fault when running acsmdownloader
> acsmdownloader -f [acsm_file] -v

Similar failure with other adept utils. For example:
> adept_activate -a




Expected result:

> acsmdownloader --version
Current libgourou version : 0.7.1

> acsmdownloader -f [ACSMFILE] -v
..
Download 100%
Created [.. title]
Loan token serialized into [..]




Actual result:
Segmentation fault (core dumped)

valgrind excerpt below

==32== Invalid read of size 4
==32==    at 0x4A08956: EVP_PKEY_get1_RSA (in 
/usr/lib/x86_64-linux-gnu/libcrypto.so.3)
==32==    by 0x1155A6: 
DRMProcessorClientImpl::RSAPrivateEncrypt(unsigned char const*, 
unsigned int, gourou::RSAInterface::RSA_KEY_TYPE, 
std::__cxx11::basic_string<char, std::char_traits<char>, 
std::allocator<char> > const&, unsigned char const*, 
unsigned int, unsigned char*) (in /usr/local/bin/acsmdownloader)
==32==    by 0x4DB0012: 
gourou::DRMProcessor::signNode(pugi::xml_node&) (in 
/usr/local/lib/libgourou.so)
==32==    by 0x4DB107F: 
gourou::DRMProcessor::fulfill(std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> > 
const&) (in /usr/local/lib/libgourou.so)
==32==    by 0x113D11: ACSMDownloader::run() (in 
/usr/local/bin/acsmdownloader)
==32==    by 0x110F13: main (in /usr/local/bin/acsmdownloader)
==32==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==32== 
==32== 
==32== Process terminating with default action of signal 11 
(SIGSEGV): dumping core
==32==  Access not within mapped region at address 0x0
==32==    at 0x4A08956: EVP_PKEY_get1_RSA (in 
/usr/lib/x86_64-linux-gnu/libcrypto.so.3)
==32==    by 0x1155A6: 
DRMProcessorClientImpl::RSAPrivateEncrypt(unsigned char const*, 
unsigned int, gourou::RSAInterface::RSA_KEY_TYPE, 
std::__cxx11::basic_string<char, std::char_traits<char>, 
std::allocator<char> > const&, unsigned char const*, 
unsigned int, unsigned char*) (in /usr/local/bin/acsmdownloader)
==32==    by 0x4DB0012: 
gourou::DRMProcessor::signNode(pugi::xml_node&) (in 
/usr/local/lib/libgourou.so)
==32==    by 0x4DB107F: 
gourou::DRMProcessor::fulfill(std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> > 
const&) (in /usr/local/lib/libgourou.so)
==32==    by 0x113D11: ACSMDownloader::run() (in 
/usr/local/bin/acsmdownloader)
==32==    by 0x110F13: main (in /usr/local/bin/acsmdownloader)

Comment 1 by Grégory Soutadé, Jun 5, 2022

This error comes with the new OpenSSL 3.
I added support for this version in master. Can you test it from 
your side before I make a release ? Thanks.

Status: Started

Comment 2 by liang, Jun 6, 2022

Working. Thanks for the fix

Comment 3 by liang, Jun 8, 2022

FYI created a Dockerfile as a way to check: 
https://github.com/bcliang/docker-libgourou

Comment 4 by Grégory Soutadé, Jun 8, 2022

Thanks, I'll put a reference to your repo on the main page !

Status: Fixed

Created: 1 year 6 days ago by liang

Updated: 1 year 19 hours ago

Status: Fixed

Followed by: 1 person

Labels:
Priority:Medium
Type:Defect