vysheng / tg

telegram-cli
GNU General Public License v2.0
6.5k stars 1.54k forks source link

Dereferencing pointer error during compile #1659

Open BaderSZ opened 4 years ago

BaderSZ commented 4 years ago

During the compiling process, I came across an dereferencing error in rsa_pem_openssl.c:41:6

Steps to reproduce:

  1. git clone --recursive repo && cd tg/
  2. remove -Werror options in Makefile and Makefile.in
  3. run ./configure && make

Output:

gcc -I. -I. -I./tgl -g -O2  -I/usr/local/include -I/usr/include -I/usr/include -I/usr/include/lua5.2  -DHAVE_CONFIG_H -Wall -Wextra -Wno-missing-field-initializers -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tgl -c -MP -MD -MF dep/crypto/rsa_pem_openssl.d -MQ objs/crypto/rsa_pem_openssl.o -o objs/crypto/rsa_pem_openssl.o tgl/crypto/rsa_pem_openssl.c
tgl/crypto/rsa_pem_openssl.c: In function ‘TGLC_rsa_new’:
tgl/crypto/rsa_pem_openssl.c:41:6: error: dereferencing pointer to incomplete type ‘RSA’ {aka ‘struct rsa_st’}
   41 |   ret->e = unwrap_bn (TGLC_bn_new ());
      |      ^~
tgl/crypto/rsa_pem_openssl.c: In function ‘TGLC_rsa_n’:
tgl/crypto/rsa_pem_openssl.c:52:1: warning: control reaches end of non-void function [-Wreturn-type]
   52 | RSA_GETTER(n);
      | ^~~~~~~~~~
tgl/crypto/rsa_pem_openssl.c: In function ‘TGLC_rsa_e’:
tgl/crypto/rsa_pem_openssl.c:53:1: warning: control reaches end of non-void function [-Wreturn-type]
   53 | RSA_GETTER(e);
      | ^~~~~~~~~~
make: *** [Makefile.tgl:20: objs/crypto/rsa_pem_openssl.o] Error 1
BaderSZ commented 4 years ago

For more information, this was tested on:

Paulchen232 commented 4 years ago

Try this: sudo apt-get install libssl1.0-dev

BaderSZ commented 4 years ago

I was able to reproduce this on Fedora 31. Both machines use openssl devel/libssl 1.1.1.

@Paulchen232 I've tested this on CentOS 7.7.1908 as well. It seems to compile with no warnings or errors on it. I'm guessing you're right and it is ssl >1.0 Neither debian sid nor fedora 31 offer openssl 1.0, since openssl <1.1.1 is considered out of support and insecure.

ShizuhaAki commented 4 years ago

Same problem here, and apt cannot find openssl 1.0

Paulchen232 commented 4 years ago

On ubuntu I think you need this: Ubuntu

BaderSZ commented 4 years ago

@Paulchen232 that won't help. You'll need to use an older distribution that still has OpenSSL 1.0. Fixing this issue for all modern Distros and OSes shouldn't depend on using outdated software.

Paulchen232 commented 4 years ago

Perhaps this help: Secure Sockets Layer toolkit - development files