View Issue Details

IDProjectCategoryView StatusLast Update
0037555FPCPackagespublic2020-09-04 21:00
ReporterBi0T1N Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0037555: Deprecation message of SSLeayversion points to wrong version and Result of _OpenSSLVersion is empty
Descriptionfunction SSLeayversion(t: cInt): string; deprecated 'For 1.1+ use OpenSSL_version';
should be
function SSLeayversion(t: cInt): string; deprecated 'For 1.1+ use OpenSSLGetVersion';
as OpenSSL_version is the internal name of OpenSSL which isn't available in the header translation.

It also seems that Result := _OpenSSLVersion(t) should be changed to Result := PChar(_OpenSSLVersion(t)) as it's done for SSLeayversion because writeln(SSLeayversion(0)); writes 'OpenSSL 1.1.1g 21 Apr 2020' while writeln(OpenSSLGetVersion(0)); does write an empty string.
TagsNo tags attached.
Fixed in Revision46759
FPCOldBugId
FPCTarget3.2.2
Attached Files

Activities

Bi0T1N

2020-08-12 18:01

reporter   ~0124803

Topic should be 'Deprecation message of SSLeayversion points to wrong function and Result of _OpenSSLVersion is empty'

Bi0T1N

2020-08-14 13:00

reporter   ~0124880

The
OpenSSL_version
function needs to be loaded through
SSLUtilHandle
.
The attached patch fixes this and also adjusts the deprecation message.
01-Fix_loading_of_OpenSSL_version_and_deprecation_message.patch (3,341 bytes)   
diff --git packages/openssl/src/openssl.pas packages/openssl/src/openssl.pas
index 1b23606217..1ec59f1575 100644
--- packages/openssl/src/openssl.pas
+++ packages/openssl/src/openssl.pas
@@ -1152,7 +1152,7 @@ var
   function EvpPkeyAssign(pkey: PEVP_PKEY; _type: cInt; key: Prsa): cInt;
   function EvpGetDigestByName(Name: String): PEVP_MD;
   procedure EVPcleanup;
-  function SSLeayversion(t: cInt): string;  deprecated 'For 1.1+ use OpenSSL_version';
+  function SSLeayversion(t: cInt): string;  deprecated 'For 1.1+ use OpenSSLGetVersion';
   procedure ErrErrorString(e: cInt; var buf: string; len: cInt);
   function ErrGetError: cInt;
   procedure ErrClearError;
@@ -1551,7 +1551,6 @@ end;
 
 type
 // libssl.dll
-  TOpenSSLversion = function (arg : cint) : pchar; cdecl;
   TSslGetError = function(s: PSSL; ret_code: cInt):cInt; cdecl;
   TSslLibraryInit = function:cInt; cdecl;
   TOPENSSL_INIT_new = function : POPENSSL_INIT_SETTINGS; cdecl;
@@ -1631,6 +1630,7 @@ type
   TEvpPkeyAssign = function(pkey: PEVP_PKEY; _type: cInt; key: Prsa): cInt; cdecl;
   TEvpGetDigestByName = function(Name: PChar): PEVP_MD; cdecl;
   TEVPcleanup = procedure; cdecl;
+  TOpenSSLversion = function (arg : cint) : pchar; cdecl;
   TSSLeayversion = function(t: cInt): PChar; cdecl;
   TErrErrorString = procedure(e: cInt; buf: PChar; len: cInt); cdecl;
   TErrGetError = function: cInt; cdecl;
@@ -1789,7 +1789,6 @@ type
 
 var
 // libssl.dll
-  _OpenSSLVersion : TOpenSSLversion = Nil;
   _SslGetError: TSslGetError = nil;
   _SslLibraryInit: TSslLibraryInit = nil;
   _OPENSSL_init_ssl : TOPENSSL_init_ssl = Nil;
@@ -1868,6 +1867,7 @@ var
   _EvpPkeyAssign: TEvpPkeyAssign = nil;
   _EvpGetDigestByName: TEvpGetDigestByName = nil;
   _EVPcleanup: TEVPcleanup = nil;
+  _OpenSSLVersion : TOpenSSLversion = Nil;
   _SSLeayversion: TSSLeayversion = nil;
   _ErrErrorString: TErrErrorString = nil;
   _ErrGetError: TErrGetError = nil;
@@ -4858,7 +4858,6 @@ end;
 Procedure LoadSSLEntryPoints;
 
 begin
-  _OpenSSLVersion := GetProcAddr(SSLLibHandle, 'OpenSSL_version');
   _SslGetError := GetProcAddr(SSLLibHandle, 'SSL_get_error');
   _SslLibraryInit := GetProcAddr(SSLLibHandle, 'SSL_library_init');
   _OPENSSL_init_ssl := GetProcAddr(SSLLibHandle, 'OPENSSL_init_ssl');
@@ -4950,9 +4949,10 @@ begin
   _EvpPkeyAssign := GetProcAddr(SSLUtilHandle, 'EVP_PKEY_assign');
   _EVPCleanup := GetProcAddr(SSLUtilHandle, 'EVP_cleanup');
   _EvpGetDigestByName := GetProcAddr(SSLUtilHandle, 'EVP_get_digestbyname');
+  _OpenSSLVersion := GetProcAddr(SSLUtilHandle, 'OpenSSL_version');
   _SSLeayversion := GetProcAddr(SSLUtilHandle, 'SSLeay_version');
   if @_SSLeayversion=Nil then
-    _SSLeayversion := GetProcAddr(SSLUtilHandle, 'OpenSSL_version');
+    _SSLeayversion := _OpenSSLVersion;
   _ErrErrorString := GetProcAddr(SSLUtilHandle, 'ERR_error_string_n');
   _ErrGetError := GetProcAddr(SSLUtilHandle, 'ERR_get_error');
   _ErrClearError := GetProcAddr(SSLUtilHandle, 'ERR_clear_error');
@@ -5217,7 +5217,6 @@ end;
 Procedure ClearSSLEntryPoints;
 
 begin
-  _OpenSSLVersion := Nil;
   _SslGetError := nil;
   _SslLibraryInit := nil;
   _OPENSSL_init_ssl:=Nil;
@@ -5396,6 +5395,7 @@ end;
 Procedure ClearUtilEntryPoints;
 
 begin
+  _OpenSSLVersion := Nil;
   _SSLeayversion := nil;
   _ERR_load_crypto_strings := nil;
   _OPENSSL_init_crypto:=Nil;

Bi0T1N

2020-08-15 23:17

reporter   ~0124911

Last edited: 2020-08-15 23:20

View 2 revisions

This second patch reuses the types and variables from
SSLeayversion
for
SSLeay_version
and also deprecates the latter one.
Noticed by trev (see https://forum.lazarus.freepascal.org/index.php/topic,51035.0.html).
02-Reuse_types_from_SSLeayversion_for_duplicate_function_SSLeay_version.patch (1,927 bytes)   
diff --git packages/openssl/src/openssl.pas packages/openssl/src/openssl.pas
index 1ec59f1575..d561dca67a 100644
--- packages/openssl/src/openssl.pas
+++ packages/openssl/src/openssl.pas
@@ -1243,7 +1243,7 @@ var
 
   // Crypto Functions
 
-  function SSLeay_version(t: cint): PChar;
+  function SSLeay_version(t: cint): PChar; deprecated 'For 1.1+ use OpenSSLGetVersion';
 
   // EVP Functions - evp.h
   function EVP_des_ede3_cbc : PEVP_CIPHER;
@@ -1716,7 +1716,6 @@ type
 
   // Crypto Functions
 
-  TSSLeay_version = function(t: cint): PChar; cdecl;
   TCRYPTOcleanupAllExData = procedure; cdecl;
   TOPENSSLaddallalgorithms = procedure; cdecl;
 
@@ -1971,7 +1970,6 @@ var
 
   // Crypto Functions
 
-  _SSLeay_version: TSSLeay_version = nil;
   _CRYPTOcleanupAllExData: TCRYPTOcleanupAllExData = nil;
   _OPENSSLaddallalgorithms: TOPENSSLaddallalgorithms = nil;
 
@@ -3350,8 +3348,8 @@ end;
 
 function SSLeay_version(t: cint): PChar;
 begin
-  if InitSSLInterface and Assigned(_SSLeay_version) then
-    Result := _SSLeay_version(t)
+  if InitSSLInterface and Assigned(_SSLeayversion) then
+    Result := _SSLeayversion(t)
   else
     Result := nil;
 end;
@@ -5090,8 +5088,6 @@ begin
   _BIO_s_file := GetProcAddr(SSLUtilHandle, 'BIO_s_file');
   _BIO_new_file := GetProcAddr(SSLUtilHandle, 'BIO_new_file');
   _BIO_new_mem_buf := GetProcAddr(SSLUtilHandle, 'BIO_new_mem_buf');
-  // Crypto Functions
-  _SSLeay_version := GetProcAddr(SSLUtilHandle, 'SSLeay_version');
   // PKCS7
   _PKCS7_ISSUER_AND_SERIAL_new:=GetProcAddr(SSLUtilHandle,'PKCS7_ISSUER_AND_SERIAL_new');
   _PKCS7_ISSUER_AND_SERIAL_free:=GetProcAddr(SSLUtilHandle,'PKCS7_ISSUER_AND_SERIAL_free');
@@ -5564,10 +5560,6 @@ begin
   _BIO_s_file := nil;
   _BIO_new_file := nil;
   _BIO_new_mem_buf := nil;
-
-  // Crypto Functions
-
-  _SSLeay_version := nil;
 end;
 
 procedure locking_callback(mode, ltype: integer; lfile: PChar; line: integer); cdecl;

Michael Van Canneyt

2020-09-04 09:18

administrator   ~0125353

Applied, thank you very much !

Issue History

Date Modified Username Field Change
2020-08-12 17:56 Bi0T1N New Issue
2020-08-12 18:01 Bi0T1N Note Added: 0124803
2020-08-14 13:00 Bi0T1N Note Added: 0124880
2020-08-14 13:00 Bi0T1N File Added: 01-Fix_loading_of_OpenSSL_version_and_deprecation_message.patch
2020-08-15 23:17 Bi0T1N Note Added: 0124911
2020-08-15 23:17 Bi0T1N File Added: 02-Reuse_types_from_SSLeayversion_for_duplicate_function_SSLeay_version.patch
2020-08-15 23:20 Bi0T1N Note Edited: 0124911 View Revisions
2020-08-20 14:14 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-08-20 14:14 Michael Van Canneyt Status new => assigned
2020-09-04 09:18 Michael Van Canneyt Status assigned => resolved
2020-09-04 09:18 Michael Van Canneyt Resolution open => fixed
2020-09-04 09:18 Michael Van Canneyt Fixed in Version => 3.3.1
2020-09-04 09:18 Michael Van Canneyt Fixed in Revision => 46759
2020-09-04 09:18 Michael Van Canneyt FPCTarget => 3.2.2
2020-09-04 09:18 Michael Van Canneyt Note Added: 0125353
2020-09-04 21:00 Bi0T1N Status resolved => closed