Skip Menu |
 

This queue is for tickets about the Net-SSLeay CPAN distribution.

Report information
The Basics
Id: 53585
Status: resolved
Worked: 1.2 hours (70 min)
Priority: 0/
Queue: Net-SSLeay

People
Owner: MIKEM [...] cpan.org
Requestors: kmx [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Attachments
0001-Use-XS-pointer-macros-for-storing-pointers-in-SVs.patch
0002-Use-XS-pointer-macros-for-storing-pointers-in-SVs.patch
0003-Change-function-signatures-to-be-const-correct.patch
0004-Handle-some-function-signatures-that-changed-in-Open.patch
0005-Fix-a-function-signature-for-0.9.8k.patch



Subject: Test failure on 64-bit (x86_64) MS Windows + gcc4 compiler
Download (untitled) / with headers
text/plain 2.1k
Hi, I have experienced a failure when trying to install Net::SSLeay (SVN version from 2009/11/26) - see enclosed log. The issue is somehow related to pointer size on 64-bit MS Windows platform. Just for your info on 64-bit MS Windows we have: 'void *' len: 4 'unsigned long int' len: 8 Thanks for any feedback on this issue. -- kmx t/handle/local/05_use.t ........ ok # compiling test program with: gcc -o t\local\ptr_cast_test t\local\ptr_cast_test.c # Failed test 'STDERR empty after compiling' # at t/local/00_ptr_cast.t line 35. # got: 't\local\ptr_cast_test.c: In function 'main': # t\local\ptr_cast_test.c:29: warning: cast from pointer to integer of different size # t\local\ptr_cast_test.c:30: warning: cast to pointer from integer of different size # t\local\ptr_cast_test.c:31: warning: cast to pointer from integer of different size # t\local\ptr_cast_test.c:37: warning: cast to pointer from integer of different size # ' # expected: '' # Looks like you failed 1 test of 5. t/local/00_ptr_cast.t .......... Dubious, test returned 1 (wstat 256, 0x100) Failed 1/5 subtests t/local/01_pod.t ............... skipped: Test::Pod 1.00 required for testing POD t/local/02_pod_coverage.t ...... skipped: currently disabled t/local/03_use.t ............... ok t/local/04_basic.t ............. ok t/local/05_passwd_cb.t ......... ok t/local/06_tcpecho.t ........... ok t/local/07_sslecho.t ........... ok t/local/08_pipe.t .............. skipped: pipes not properly supported on Windows t/local/15_bio.t ............... ok t/local/20_autoload.t .......... skipped: Some tests need Test::Exception t/local/30_error.t ............. skipped: Requires Test::Exception, Test::Warn and Test::NoWarnings t/local/31_rsa_generate_key.t .. skipped: Test::Exception required t/local/35_ephemeral.t ......... ok t/local/50_digest.t ............ ok t/local/kwalitee.t ............. skipped: Needs Test::Kwalitee Test Summary Report ------------------- t/local/00_ptr_cast.t (Wstat: 256 Tests: 5 Failed: 1) Failed test: 2 Non-zero exit status: 1 Files=17, Tests=132, 4 wallclock secs ( 0.06 usr + 0.11 sys = 0.17 CPU) Result: FAIL
Download (untitled) / with headers
text/plain 109b
Sorry for typo - the right sizeofs on 64-bit MSWin: sizeof(void *) : 8 sizeof(unsigned long int) : 4 -- kmx
Download (untitled) / with headers
text/plain 453b
And one totally insignificant patch to t/local/ptr_cast_test.c - printf("# %s: '%s' len: %ul, '%s' len: %ul.\n", argv[0], FROMTYPESTR, - (int)sizeof(TOTYPE), TOTYPESTR, (int)sizeof(char *)); + printf("# %s: '%s' len: %ul, '%s' len: %ul.\n", argv[0], TOTYPESTR, + (int)sizeof(TOTYPE), FROMTYPESTR, (int)sizeof(FROMTYPE)); Currently the output sizes are swapped (which is absolutely harmless; it just confused me a little bit). -- kmx
Sorry for reopening this ticket again but the main issue is still present in Net-SSLeay-1.36

The problem is the following failing test which fails only on 64-bit MS Windows:

t/local/00_ptr_cast.t .......... # compiling test program with: gcc -o t\local\ptr_cast_test t\local\ptr_cast_test.c
t/local/00_ptr_cast.t .......... 1/5
Show quoted text
#   Failed test 'STDERR empty after compiling'
#   at t/local/00_ptr_cast.t line 35.
#          got: 't\local\ptr_cast_test.c: In function 'main':
# t\local\ptr_cast_test.c:29: warning: cast from pointer to integer of different size
# t\local\ptr_cast_test.c:30: warning: cast to pointer from integer of different size
# t\local\ptr_cast_test.c:31: warning: cast to pointer from integer of different size
# t\local\ptr_cast_test.c:37: warning: cast to pointer from integer of different size
# '
#     expected: ''
# Looks like you failed 1 test of 5.
t/local/00_ptr_cast.t .......... Dubious, test returned 1 (wstat 256, 0x100)

The reason is that on 64-bit MS Windows the size of "unsigned long int" and "void *" are not the same
- 'void *' has size 8 bytes
- 'unsigned long int' has size 4 bytes

So trying to assign a pointer to 'unsigned long int' variable ends up with the warning:
warning: cast from pointer to integer of different size

To be honest I do not know what is the reason for this kind of test as Net::SSLeay module does not seem to use assignments between pointers and integers. As for the openssl library at least version 1.0.0 is officially supported on 64-bit MS Windows (I am using 64bit compiler by mingw-w64.sf.net project) so it obviously has to count with this differences in pointer vs. int sizes.

Maybe there are some reasons for this test when using openssl 0.9.x - in that case I propose to skip this test when using openssl-1.0.0.

--
kmx


Hi, it is more than a year since I have reported this issue.

Would it be possible to make some progress?

Can I help somehow?

Thanks.

--
kmx

Download (untitled) / with headers
text/plain 125b
For those who are interested, I have attached a patch here that will handle pointers using perl XS macros instead of casting.
Subject: 0001-Use-XS-pointer-macros-for-storing-pointers-in-SVs.patch
From e774610c2310c25816e36306f45caaa8e40780a3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson <doug@somethingdoug.com> Date: Thu, 22 Sep 2011 17:30:05 -0400 Subject: [PATCH] Use XS pointer macros for storing pointers in SVs Fix the typemap so that pointer types are of type T_PTR which generates XS code using the INT2PTR and PTR2IV macros which store pointers in an IV. Since an IV is guaranted to be at least the size of a pointer, no information is lost. Previously the pointers were cast to unsigned long int which resulted in a loss on 64-bit systems where long int was only 4 bytes. Also removed the pointer cast test since pointers are not being cast anymore and are handled by the macros designed for the job. --- MANIFEST | 2 - SSLeay.xs | 4 +- t/local/00_ptr_cast.t | 43 --------------------- t/local/ptr_cast_test.c | 43 --------------------- typemap | 94 +++++++++++++++++++++++----------------------- 5 files changed, 49 insertions(+), 137 deletions(-) delete mode 100644 t/local/00_ptr_cast.t delete mode 100644 t/local/ptr_cast_test.c diff --git a/MANIFEST b/MANIFEST index 4512a5d..099063a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -55,7 +55,6 @@ t/external/15_altnames.t t/handle/external/10_destroy.t t/handle/external/50_external.t t/handle/local/05_use.t -t/local/00_ptr_cast.t t/local/01_pod.t t/local/02_pod_coverage.t t/local/03_use.t @@ -71,6 +70,5 @@ t/local/31_rsa_generate_key.t t/local/35_ephemeral.t t/local/50_digest.t t/local/kwalitee.t -t/local/ptr_cast_test.c TODO typemap diff --git a/SSLeay.xs b/SSLeay.xs index f9d1caa..1e7cf26 100644 --- a/SSLeay.xs +++ b/SSLeay.xs @@ -182,7 +182,7 @@ ssleay_verify_callback_invoke (int ok, X509_STORE_CTX* x509_store) { PUSHMARK(sp); EXTEND( sp, 2 ); PUSHs( sv_2mortal(newSViv(ok)) ); - PUSHs( sv_2mortal(newSViv((unsigned long int)x509_store)) ); + PUSHs( sv_2mortal(newSViv(PTR2IV(x509_store))) ); PUTBACK; PR("About to call verify callback.\n"); @@ -2863,7 +2863,7 @@ SSL_CTX_set1_param(ctx, vpm) int SSL_set1_param(ctx, vpm) - SSL_CTX * ctx + SSL * ctx X509_VERIFY_PARAM *vpm #endif diff --git a/t/local/00_ptr_cast.t b/t/local/00_ptr_cast.t deleted file mode 100644 index 6293de6..0000000 --- a/t/local/00_ptr_cast.t +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use File::Spec; -use Test::More tests => 5; -use Symbol qw(gensym); -use IPC::Open3; -use Config; - -my $input = File::Spec->catfile(qw( t local ptr_cast_test.c )); -my $output = File::Spec->catfile(qw( t local ptr_cast_test )); - -unlink $output; - -my $out = gensym(); -my $err = gensym(); - -my @extraargs; -my $cmd; -if($^O eq 'MSWin32' && $Config{cc} eq 'cl') { - push(@extraargs, '/nologo ' . $Config{libs}); - $cmd = "$Config{cc} /Fe$output $input " . join(' ', @extraargs); -} -else { - push(@extraargs, '-Zexe') if $^O eq 'os2'; - $cmd = "$Config{cc} $Config{ccflags} -o $output $input " . join(' ', @extraargs) -} -diag( "compiling test program with: $cmd" ); -my $pid = open3(undef, $out, $err, $cmd); -waitpid $pid, 0; - -is( $?, 0, 'compiling ptr_cast_test.c' ); - -is( do { local $/ = undef; <$err>}, '', 'STDERR empty after compiling' ); - -$pid = open3(undef, $out, $err, "./$output"); -waitpid $pid, 0; - -is( $?, 0, './ptr_cast_test exited with 0' ); - -like( do { local $/ = undef; <$out> }, qr/ptr_cast_test:\s+ok\s+/, 'casting pointer integer and back worked' ); -ok( !do { local $/ = undef; <$err> }, 'STDERR empty after running' ); diff --git a/t/local/ptr_cast_test.c b/t/local/ptr_cast_test.c deleted file mode 100644 index 15084b7..0000000 --- a/t/local/ptr_cast_test.c +++ /dev/null @@ -1,43 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> - -/* test if a pointer can be cast to an unsigned long int and back - (aspa@hip.fi) - - tested on: HP-UX B.10.20, AIX 4.3, IRIX 5.3, OSF1 v4.0B and SunOS 5.6 - with both gcc and native compilers, and linux/gcc (i686) + - linux/gcc (alpha). - -*/ - -#define FROMTYPE void * -#define FROMTYPESTR "void *" -#define TOTYPE unsigned long int -#define TOTYPESTR "unsigned long int" - -int main(argc, argv) - int argc; /* e.g. HP-UX cc doesn't support ISO C by default */ - char *argv[]; -{ - /* heap should be near the end of process's address space */ - FROMTYPE bufptr = (FROMTYPE) malloc(500); - volatile TOTYPE i; /* prevent optimization */ - - printf("# %s: '%s' len: %ul, '%s' len: %ul.\n", argv[0], FROMTYPESTR, - (int)sizeof(TOTYPE), TOTYPESTR, (int)sizeof(char *)); - - i = (TOTYPE)bufptr; - if( ((FROMTYPE)i) != bufptr ) { - printf("# %s: failed: (%p != %p).\n", argv[0], (FROMTYPE)i, bufptr); - printf("# ERROR: a '%s' can't be cast to a '%s' and back \n", - FROMTYPESTR, TOTYPESTR); - printf("# ERROR: without loss of information on this architecture.\n"); - exit(1); - } else { - printf("# ptr_cast_test: ok (%p == %p).\n", (FROMTYPE)i, bufptr); - exit(0); - } - - exit(1); -} - diff --git a/typemap b/typemap index 47c4f75..b7852f5 100644 --- a/typemap +++ b/typemap @@ -1,53 +1,53 @@ TYPEMAP -SSL_METHOD * T_IV -SSL_CTX * T_IV -SSL_SESSION * T_IV -SSL * T_IV -RSA * T_IV -DH * T_IV -X509 * T_IV -X509_CRL * T_IV -X509_LOOKUP * T_IV -X509_NAME * T_IV -X509_EXTENSION * T_IV -BIO * T_IV -BIO_METHOD * T_IV -EVP_PKEY * T_IV -const EVP_MD * T_IV -CERT * T_IV -LHASH * T_IV -struct lhash_st_SSL_SESSION * T_IV -struct cert_st * T_IV -X509_STORE_CTX * T_IV -ASN1_UTCTIME * T_IV -ASN1_OCTET_STRING * T_IV -EVP_PKEY * T_IV +SSL_METHOD * T_PTR +SSL_CTX * T_PTR +SSL_SESSION * T_PTR +SSL * T_PTR +RSA * T_PTR +DH * T_PTR +X509 * T_PTR +X509_CRL * T_PTR +X509_LOOKUP * T_PTR +X509_NAME * T_PTR +X509_EXTENSION * T_PTR +BIO * T_PTR +BIO_METHOD * T_PTR +EVP_PKEY * T_PTR +const EVP_MD * T_PTR +CERT * T_PTR +LHASH * T_PTR +struct lhash_st_SSL_SESSION * T_PTR +struct cert_st * T_PTR +X509_STORE_CTX * T_PTR +ASN1_UTCTIME * T_PTR +ASN1_OCTET_STRING * T_PTR +EVP_PKEY * T_PTR const char * T_PV const unsigned char * T_PV -CRYPTO_EX_new * T_IV -CRYPTO_EX_dup * T_IV -CRYPTO_EX_free * T_IV -SSL_CIPHER * T_IV -int * T_IV -COMP_METHOD * T_IV -X509_STORE * T_IV -X509_NAME_STACK * T_IV -X509_VERIFY_PARAM * T_IV -X509_POLICY_LEVEL * T_IV -X509_POLICY_TREE * T_IV -X509_POLICY_NODE * T_IV -STACK_OF(X509_POLICY_NODE) * T_IV -STACK_OF(POLICYQUALINFO) * T_IV -ASN1_OBJECT * T_IV -STACK_OF(ASN1_OBJECT) * T_IV -ENGINE * T_IV -pem_password_cb * T_IV -generate_key_cb * T_IV -callback_ret_int * T_IV -callback_no_ret * T_IV -cb_ssl_int_int_ret_void * T_IV -cb_ssl_int_int_ret_RSA * T_IV -cb_ssl_int_int_ret_DH * T_IV +CRYPTO_EX_new * T_PTR +CRYPTO_EX_dup * T_PTR +CRYPTO_EX_free * T_PTR +SSL_CIPHER * T_PTR +int * T_PTR +COMP_METHOD * T_PTR +X509_STORE * T_PTR +X509_NAME_STACK * T_PTR +X509_VERIFY_PARAM * T_PTR +X509_POLICY_LEVEL * T_PTR +X509_POLICY_TREE * T_PTR +X509_POLICY_NODE * T_PTR +STACK_OF(X509_POLICY_NODE) * T_PTR +STACK_OF(POLICYQUALINFO) * T_PTR +ASN1_OBJECT * T_PTR +STACK_OF(ASN1_OBJECT) * T_PTR +ENGINE * T_PTR +pem_password_cb * T_PTR +generate_key_cb * T_PTR +callback_ret_int * T_PTR +callback_no_ret * T_PTR +cb_ssl_int_int_ret_void * T_PTR +cb_ssl_int_int_ret_RSA * T_PTR +cb_ssl_int_int_ret_DH * T_PTR perl_filehandle_t T_PERL_IO_HANDLE INPUT -- 1.7.6.msysgit.0
Download (untitled) / with headers
text/plain 728b
On Thu Sep 22 17:42:52 2011, DOUGDUDE wrote: Show quoted text
> For those who are interested, I have attached a patch here that will > handle pointers using perl XS macros instead of casting.
Hi Doug, thanks for the patch, but I am a but undertain as to some of the contents. There seem to be some unnecessary changes. I can see the change that uses PTR2IV instead of unsigned long int, but there is also a change in the argument to SSL_set1_param from SSL to SSL_CTX. That look OK, but its a different topic. You have also removed 2 test files: is that correct? I can see in typemap you change the type of many args, but there is also a line 54 deleted that contains a -, however that is not in my source. Can you clarify? Cheers.
Download (untitled) / with headers
text/plain 1.8k
On Thu Sep 22 18:34:17 2011, MIKEM wrote: Show quoted text
> On Thu Sep 22 17:42:52 2011, DOUGDUDE wrote:
> > For those who are interested, I have attached a patch here that will > > handle pointers using perl XS macros instead of casting.
> > Hi Doug, > > thanks for the patch, but I am a but undertain as to some of the > contents. There seem to be some unnecessary changes. > > I can see the change that uses PTR2IV instead of unsigned long int, > but there is also a change in the argument to SSL_set1_param from SSL > to SSL_CTX. That look OK, but its a different topic. >
Yes, sorry, the SSL_set1_param change made it into the patch by mistake. Show quoted text
> You have also removed 2 test files: is that correct? >
Correct, the patch removes them. From looking over the code, it came to my understanding the purpose of the test files was to determine if (void *) could be cast to (unsigned long int) and back again without data loss. Since all the XS code stores the pointers into an IV using the macros PTR2IV and back again with INT2PTR. Since perl guarantees that the IV will be at least the size of a pointer on the platform, Perl is guaranteeing that there will be no information loss when storing/retrieving the pointer. Show quoted text
> > I can see in typemap you change the type of many args, but there is > also a line 54 deleted that contains a -, however that is not in my > source. > > Can you clarify? >
That "--" below INPUT is actually is a marker for the end off the diff that git outputs. At the top of the diff for typemap you can see it show 53 lines in both before and after. Also, the reason their types where changed is that a type of T_PTR will cause xsubpp to generate the proper code that uses the PTR2IV and INT2PTR macros. Show quoted text
> Cheers. >
I've attached a path here without the SSL_set1_param change. This new patch also applies to SVN revision 275 instead of the CPAN release.
Subject: 0002-Use-XS-pointer-macros-for-storing-pointers-in-SVs.patch
From c49af36bb2f94582c1bd14f9ec7acead49315b55 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson <doug@somethingdoug.com> Date: Thu, 22 Sep 2011 17:30:05 -0400 Subject: [PATCH] Use XS pointer macros for storing pointers in SVs Fix the typemap so that pointer types are of type T_PTR which generates XS code using the INT2PTR and PTR2IV macros which store pointers in an IV. Since an IV is guaranted to be at least the size of a pointer, no information is lost. Previously the pointers were cast to unsigned long int which resulted in a loss on 64-bit systems where long int was only 4 bytes. Also removed the pointer cast test since pointers are not being cast anymore and are handled by the macros designed for the job. --- SSLeay.xs | 2 +- t/local/00_ptr_cast.t | 43 --------------------- t/local/ptr_cast_test.c | 43 --------------------- typemap | 94 +++++++++++++++++++++++----------------------- 4 files changed, 48 insertions(+), 134 deletions(-) delete mode 100644 t/local/00_ptr_cast.t delete mode 100644 t/local/ptr_cast_test.c diff --git a/SSLeay.xs b/SSLeay.xs index 5fbbc5f..7fa0fe6 100644 --- a/SSLeay.xs +++ b/SSLeay.xs @@ -182,7 +182,7 @@ ssleay_verify_callback_invoke (int ok, X509_STORE_CTX* x509_store) { PUSHMARK(sp); EXTEND( sp, 2 ); PUSHs( sv_2mortal(newSViv(ok)) ); - PUSHs( sv_2mortal(newSViv((unsigned long int)x509_store)) ); + PUSHs( sv_2mortal(newSViv(PTR2IV(x509_store))) ); PUTBACK; PR("About to call verify callback.\n"); diff --git a/t/local/00_ptr_cast.t b/t/local/00_ptr_cast.t deleted file mode 100644 index 6293de6..0000000 --- a/t/local/00_ptr_cast.t +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use File::Spec; -use Test::More tests => 5; -use Symbol qw(gensym); -use IPC::Open3; -use Config; - -my $input = File::Spec->catfile(qw( t local ptr_cast_test.c )); -my $output = File::Spec->catfile(qw( t local ptr_cast_test )); - -unlink $output; - -my $out = gensym(); -my $err = gensym(); - -my @extraargs; -my $cmd; -if($^O eq 'MSWin32' && $Config{cc} eq 'cl') { - push(@extraargs, '/nologo ' . $Config{libs}); - $cmd = "$Config{cc} /Fe$output $input " . join(' ', @extraargs); -} -else { - push(@extraargs, '-Zexe') if $^O eq 'os2'; - $cmd = "$Config{cc} $Config{ccflags} -o $output $input " . join(' ', @extraargs) -} -diag( "compiling test program with: $cmd" ); -my $pid = open3(undef, $out, $err, $cmd); -waitpid $pid, 0; - -is( $?, 0, 'compiling ptr_cast_test.c' ); - -is( do { local $/ = undef; <$err>}, '', 'STDERR empty after compiling' ); - -$pid = open3(undef, $out, $err, "./$output"); -waitpid $pid, 0; - -is( $?, 0, './ptr_cast_test exited with 0' ); - -like( do { local $/ = undef; <$out> }, qr/ptr_cast_test:\s+ok\s+/, 'casting pointer integer and back worked' ); -ok( !do { local $/ = undef; <$err> }, 'STDERR empty after running' ); diff --git a/t/local/ptr_cast_test.c b/t/local/ptr_cast_test.c deleted file mode 100644 index 15084b7..0000000 --- a/t/local/ptr_cast_test.c +++ /dev/null @@ -1,43 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> - -/* test if a pointer can be cast to an unsigned long int and back - (aspa@hip.fi) - - tested on: HP-UX B.10.20, AIX 4.3, IRIX 5.3, OSF1 v4.0B and SunOS 5.6 - with both gcc and native compilers, and linux/gcc (i686) + - linux/gcc (alpha). - -*/ - -#define FROMTYPE void * -#define FROMTYPESTR "void *" -#define TOTYPE unsigned long int -#define TOTYPESTR "unsigned long int" - -int main(argc, argv) - int argc; /* e.g. HP-UX cc doesn't support ISO C by default */ - char *argv[]; -{ - /* heap should be near the end of process's address space */ - FROMTYPE bufptr = (FROMTYPE) malloc(500); - volatile TOTYPE i; /* prevent optimization */ - - printf("# %s: '%s' len: %ul, '%s' len: %ul.\n", argv[0], FROMTYPESTR, - (int)sizeof(TOTYPE), TOTYPESTR, (int)sizeof(char *)); - - i = (TOTYPE)bufptr; - if( ((FROMTYPE)i) != bufptr ) { - printf("# %s: failed: (%p != %p).\n", argv[0], (FROMTYPE)i, bufptr); - printf("# ERROR: a '%s' can't be cast to a '%s' and back \n", - FROMTYPESTR, TOTYPESTR); - printf("# ERROR: without loss of information on this architecture.\n"); - exit(1); - } else { - printf("# ptr_cast_test: ok (%p == %p).\n", (FROMTYPE)i, bufptr); - exit(0); - } - - exit(1); -} - diff --git a/typemap b/typemap index 47c4f75..b7852f5 100644 --- a/typemap +++ b/typemap @@ -1,53 +1,53 @@ TYPEMAP -SSL_METHOD * T_IV -SSL_CTX * T_IV -SSL_SESSION * T_IV -SSL * T_IV -RSA * T_IV -DH * T_IV -X509 * T_IV -X509_CRL * T_IV -X509_LOOKUP * T_IV -X509_NAME * T_IV -X509_EXTENSION * T_IV -BIO * T_IV -BIO_METHOD * T_IV -EVP_PKEY * T_IV -const EVP_MD * T_IV -CERT * T_IV -LHASH * T_IV -struct lhash_st_SSL_SESSION * T_IV -struct cert_st * T_IV -X509_STORE_CTX * T_IV -ASN1_UTCTIME * T_IV -ASN1_OCTET_STRING * T_IV -EVP_PKEY * T_IV +SSL_METHOD * T_PTR +SSL_CTX * T_PTR +SSL_SESSION * T_PTR +SSL * T_PTR +RSA * T_PTR +DH * T_PTR +X509 * T_PTR +X509_CRL * T_PTR +X509_LOOKUP * T_PTR +X509_NAME * T_PTR +X509_EXTENSION * T_PTR +BIO * T_PTR +BIO_METHOD * T_PTR +EVP_PKEY * T_PTR +const EVP_MD * T_PTR +CERT * T_PTR +LHASH * T_PTR +struct lhash_st_SSL_SESSION * T_PTR +struct cert_st * T_PTR +X509_STORE_CTX * T_PTR +ASN1_UTCTIME * T_PTR +ASN1_OCTET_STRING * T_PTR +EVP_PKEY * T_PTR const char * T_PV const unsigned char * T_PV -CRYPTO_EX_new * T_IV -CRYPTO_EX_dup * T_IV -CRYPTO_EX_free * T_IV -SSL_CIPHER * T_IV -int * T_IV -COMP_METHOD * T_IV -X509_STORE * T_IV -X509_NAME_STACK * T_IV -X509_VERIFY_PARAM * T_IV -X509_POLICY_LEVEL * T_IV -X509_POLICY_TREE * T_IV -X509_POLICY_NODE * T_IV -STACK_OF(X509_POLICY_NODE) * T_IV -STACK_OF(POLICYQUALINFO) * T_IV -ASN1_OBJECT * T_IV -STACK_OF(ASN1_OBJECT) * T_IV -ENGINE * T_IV -pem_password_cb * T_IV -generate_key_cb * T_IV -callback_ret_int * T_IV -callback_no_ret * T_IV -cb_ssl_int_int_ret_void * T_IV -cb_ssl_int_int_ret_RSA * T_IV -cb_ssl_int_int_ret_DH * T_IV +CRYPTO_EX_new * T_PTR +CRYPTO_EX_dup * T_PTR +CRYPTO_EX_free * T_PTR +SSL_CIPHER * T_PTR +int * T_PTR +COMP_METHOD * T_PTR +X509_STORE * T_PTR +X509_NAME_STACK * T_PTR +X509_VERIFY_PARAM * T_PTR +X509_POLICY_LEVEL * T_PTR +X509_POLICY_TREE * T_PTR +X509_POLICY_NODE * T_PTR +STACK_OF(X509_POLICY_NODE) * T_PTR +STACK_OF(POLICYQUALINFO) * T_PTR +ASN1_OBJECT * T_PTR +STACK_OF(ASN1_OBJECT) * T_PTR +ENGINE * T_PTR +pem_password_cb * T_PTR +generate_key_cb * T_PTR +callback_ret_int * T_PTR +callback_no_ret * T_PTR +cb_ssl_int_int_ret_void * T_PTR +cb_ssl_int_int_ret_RSA * T_PTR +cb_ssl_int_int_ret_DH * T_PTR perl_filehandle_t T_PERL_IO_HANDLE INPUT -- 1.7.6.msysgit.0
Download (untitled) / with headers
text/plain 319b
Also as a clarification, the changes in this patch should not affect backwards compatibility as the pointers are still stored in the exact same manor: in the IV part of a SV. This just changes the method of converting the pointer to an IV (changing it to work no matter what the size of the pointers on a platform are).
Download (untitled) / with headers
text/plain 480b
Hi Doug, thanks. I have now uploaded a new 1.40 with your patches. Let me know how you go. Cheers. On Thu Sep 22 22:24:20 2011, DOUGDUDE wrote: Show quoted text
> Also as a clarification, the changes in this patch should not affect > backwards compatibility as the pointers are still stored in the
exact Show quoted text
> same manor: in the IV part of a SV. This just changes the method of > converting the pointer to an IV (changing it to work no matter what
the Show quoted text
> size of the pointers on a platform are).
Download (untitled) / with headers
text/plain 374b
On Thu Sep 22 22:43:45 2011, MIKEM wrote: Show quoted text
> Hi Doug, > > thanks. > I have now uploaded a new 1.40 with your patches. > Let me know how you go. > > Cheers. >
Thank you for the quick responses (: version 1.40 successfully installed on my 64-bit perl+ubuntu, 32-bit perl+ubuntu and on 64-bit perl+windows. I can only hope that the patch goes through smooth on all systems.
Hi,

thanks for your effort. Version 1.40 installs fine on MS Windows 64bit Strawberry perl.

There are just some compiler warnings:

SSLeay.c: In function 'XS_Net__SSLeay_SSLv3_method':
SSLeay.c:4804: warning: assignment discards qualifiers from pointer target type
SSLeay.c: In function 'XS_Net__SSLeay_TLSv1_method':
SSLeay.c:4825: warning: assignment discards qualifiers from pointer target type
SSLeay.c: In function 'XS_Net__SSLeay_get_ssl_method':
SSLeay.c:4870: warning: assignment discards qualifiers from pointer target type
SSLeay.c: In function 'XS_Net__SSLeay_get_current_cipher':
SSLeay.c:6086: warning: assignment discards qualifiers from pointer target type
SSLeay.c: In function 'XS_Net__SSLeay_X509_VERIFY_PARAM_lookup':
SSLeay.c:8665: warning: assignment discards qualifiers from pointer target type
SSLeay.c: In function 'XS_Net__SSLeay_X509_policy_node_get0_policy':
SSLeay.c:8858: warning: assignment discards qualifiers from pointer target type
SSLeay.c: In function 'XS_Net__SSLeay_X509_policy_node_get0_parent':
SSLeay.c:8902: warning: assignment discards qualifiers from pointer target type

which is IMHO only related to 'SSL_METHOD *' vs 'const SSL_METHOD *' issue.

Anyway thanks for your time.

--
kmx

Download (untitled) / with headers
text/plain 1.8k
On Fri Sep 23 03:14:56 2011, KMX wrote: Show quoted text
> Hi, > > thanks for your effort. Version 1.40 installs fine on MS Windows 64bit > Strawberry perl. > > There are just some compiler warnings: > > SSLeay.c: In function 'XS_Net__SSLeay_SSLv3_method': > SSLeay.c:4804: warning: assignment discards qualifiers from pointer > target type > SSLeay.c: In function 'XS_Net__SSLeay_TLSv1_method': > SSLeay.c:4825: warning: assignment discards qualifiers from pointer > target type > SSLeay.c: In function 'XS_Net__SSLeay_get_ssl_method': > SSLeay.c:4870: warning: assignment discards qualifiers from pointer > target type > SSLeay.c: In function 'XS_Net__SSLeay_get_current_cipher': > SSLeay.c:6086: warning: assignment discards qualifiers from pointer > target type > SSLeay.c: In function 'XS_Net__SSLeay_X509_VERIFY_PARAM_lookup': > SSLeay.c:8665: warning: assignment discards qualifiers from pointer > target type > SSLeay.c: In function 'XS_Net__SSLeay_X509_policy_node_get0_policy': > SSLeay.c:8858: warning: assignment discards qualifiers from pointer > target type > SSLeay.c: In function 'XS_Net__SSLeay_X509_policy_node_get0_parent': > SSLeay.c:8902: warning: assignment discards qualifiers from pointer > target type > > which is IMHO only related to 'SSL_METHOD *' vs 'const SSL_METHOD *' > issue. > > Anyway thanks for your time. > > -- > kmx
Yea. I looked into that, but I'm not sure how to fix it. The problem is that those functions return constant pointers, but the assignment is to a non-constant. Even then, the constantness would be stripped anyway when it was changed into an IV in Perl, so there isn't a way I know of for the XS to be constant-correct there. Since I do not know the answer and the warnings to not harm the functionality (plus they have been there for a long time) I didn't have time to spend trying to see how to silence them (plus they don't hurt the functionality).
Download (untitled) / with headers
text/plain 550b
KMX, after further investigation it turned out when I was trying to correct those warnings, I was changing code that did not apply to the version of OpenSSL I have installed, and thus why I never saw results. I have attached a patch here which changes those function signatures to be constant. I have only tests these changes on OpenSSL 1.0.0, though, so I am not sure if they will break anything in older versions (though I doubt it). Before I changed any of the signatures, I checked with the OpenSSL header files to be sure the signature matched.
Subject: 0003-Change-function-signatures-to-be-const-correct.patch
From f87d4c9a4f85694c3643be41ff5c0a0a16a0be33 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson <doug@somethingdoug.com> Date: Fri, 23 Sep 2011 14:17:40 -0400 Subject: [PATCH] Change function signatures to be const-correct There were various function signatures where OpenSSL returned a constant pointer but that was not honored in the XS code. These functions signatures have been changed to look for a const. --- SSLeay.xs | 30 +++++++++++++++--------------- typemap | 7 +++++-- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/SSLeay.xs b/SSLeay.xs index 7fa0fe6..0943c50 100644 --- a/SSLeay.xs +++ b/SSLeay.xs @@ -1916,24 +1916,24 @@ RIPEMD160(data) #ifndef OPENSSL_NO_SSL2 #if OPENSSL_VERSION_NUMBER < 0x10000000L -SSL_METHOD * +const SSL_METHOD * SSLv2_method() #endif #endif -SSL_METHOD * +const SSL_METHOD * SSLv3_method() -SSL_METHOD * +const SSL_METHOD * TLSv1_method() int SSL_set_ssl_method(ssl, method) - SSL * ssl - SSL_METHOD * method + SSL * ssl + const SSL_METHOD * method -SSL_METHOD * +const SSL_METHOD * SSL_get_ssl_method(ssl) SSL * ssl @@ -2045,13 +2045,13 @@ SSL_check_private_key(ctx) char * SSL_CIPHER_description(cipher,buf,size) - SSL_CIPHER * cipher + const SSL_CIPHER * cipher char * buf int size int SSL_CIPHER_get_bits(c,alg_bits) - SSL_CIPHER * c + const SSL_CIPHER * c int * alg_bits int @@ -2176,7 +2176,7 @@ SSL_CTX_set_quiet_shutdown(ctx,mode) int SSL_CTX_set_ssl_version(ctx,meth) SSL_CTX * ctx - SSL_METHOD * meth + const SSL_METHOD * meth long SSL_CTX_set_timeout(ctx,t) @@ -2221,7 +2221,7 @@ SSL * SSL_dup(ssl) SSL * ssl -SSL_CIPHER * +const SSL_CIPHER * SSL_get_current_cipher(s) SSL * s @@ -2944,7 +2944,7 @@ int X509_VERIFY_PARAM_add0_table(param) X509_VERIFY_PARAM *param -X509_VERIFY_PARAM * +const X509_VERIFY_PARAM * X509_VERIFY_PARAM_lookup(name) const char *name @@ -2981,17 +2981,17 @@ X509_policy_level_get0_node(level, i) X509_POLICY_LEVEL *level int i -ASN1_OBJECT * +const ASN1_OBJECT * X509_policy_node_get0_policy(node) - X509_POLICY_NODE *node + const X509_POLICY_NODE *node STACK_OF(POLICYQUALINFO) * X509_policy_node_get0_qualifiers(node) X509_POLICY_NODE *node -X509_POLICY_NODE * +const X509_POLICY_NODE * X509_policy_node_get0_parent(node) - X509_POLICY_NODE *node + const X509_POLICY_NODE *node #endif diff --git a/typemap b/typemap index b7852f5..5734b4f 100644 --- a/typemap +++ b/typemap @@ -1,5 +1,5 @@ TYPEMAP -SSL_METHOD * T_PTR +const SSL_METHOD * T_PTR SSL_CTX * T_PTR SSL_SESSION * T_PTR SSL * T_PTR @@ -27,18 +27,21 @@ const unsigned char * T_PV CRYPTO_EX_new * T_PTR CRYPTO_EX_dup * T_PTR CRYPTO_EX_free * T_PTR -SSL_CIPHER * T_PTR +const SSL_CIPHER * T_PTR int * T_PTR COMP_METHOD * T_PTR X509_STORE * T_PTR X509_NAME_STACK * T_PTR X509_VERIFY_PARAM * T_PTR +const X509_VERIFY_PARAM * T_PTR X509_POLICY_LEVEL * T_PTR X509_POLICY_TREE * T_PTR X509_POLICY_NODE * T_PTR +const X509_POLICY_NODE * T_PTR STACK_OF(X509_POLICY_NODE) * T_PTR STACK_OF(POLICYQUALINFO) * T_PTR ASN1_OBJECT * T_PTR +const ASN1_OBJECT * T_PTR STACK_OF(ASN1_OBJECT) * T_PTR ENGINE * T_PTR pem_password_cb * T_PTR -- 1.7.6.msysgit.0
Download (untitled) / with headers
text/plain 845b
Hi Douglas, thanks for this patch. It does indeed fix the warnings in 1.0, but introduces some when compiled against 0.9.8. Nevertheless, I have added your patch to svn. It will appear in a forthcoming release. Cheers. On Fri Sep 23 14:22:24 2011, DOUGDUDE wrote: Show quoted text
> KMX, after further investigation it turned out when I was trying to > correct those warnings, I was changing code that did not apply to
the Show quoted text
> version of OpenSSL I have installed, and thus why I never saw
results. Show quoted text
> > I have attached a patch here which changes those function signatures
to Show quoted text
> be constant. I have only tests these changes on OpenSSL 1.0.0,
though, Show quoted text
> so I am not sure if they will break anything in older versions
(though I Show quoted text
> doubt it). Before I changed any of the signatures, I checked with
the Show quoted text
> OpenSSL header files to be sure the signature matched.
Download (untitled) / with headers
text/plain 489b
On Fri Sep 23 17:05:34 2011, MIKEM wrote: Show quoted text
> Hi Douglas, > > thanks for this patch. > It does indeed fix the warnings in 1.0, but introduces some when > compiled against 0.9.8. > Nevertheless, I have added your patch to svn. It will appear in a > forthcoming release. > > Cheers. >
MIKEM, Unless you end up needing to release it quickly, if you want to wait for a bit, I'm going to get the 0.9.8 OpenSSL libraries and link against them and see what is causing the new warnings there.
Download (untitled) / with headers
text/plain 245b
Ok. The reason those warnings popped up is because 2 methods before 1.0.0 took an SSL_METHOD pointer not as a const while in 1.0.0 they are const. I've attached a patch that chooses the correct signature. This is tested against 1.0.0 and 0.9.8q.
Subject: 0004-Handle-some-function-signatures-that-changed-in-Open.patch
From 26a50987f7a9ad81954752490b92734d1d34138d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson <doug@somethingdoug.com> Date: Sat, 24 Sep 2011 03:12:12 -0400 Subject: [PATCH] Handle some function signatures that changed in OpenSSL 1.0.0 --- SSLeay.xs | 22 ++++++++++++++++++++++ typemap | 1 + 2 files changed, 23 insertions(+), 0 deletions(-) diff --git a/SSLeay.xs b/SSLeay.xs index 62cde30..57bc238 100644 --- a/SSLeay.xs +++ b/SSLeay.xs @@ -1873,11 +1873,22 @@ SSLv3_method() const SSL_METHOD * TLSv1_method() +#if OPENSSL_VERSION_NUMBER < 0x10000000L + +int +SSL_set_ssl_method(ssl, method) + SSL * ssl + SSL_METHOD * method + +#else + int SSL_set_ssl_method(ssl, method) SSL * ssl const SSL_METHOD * method +#endif + const SSL_METHOD * SSL_get_ssl_method(ssl) SSL * ssl @@ -2118,11 +2129,22 @@ SSL_CTX_set_quiet_shutdown(ctx,mode) SSL_CTX * ctx int mode +#if OPENSSL_VERSION_NUMBER < 0x10000000L + +int +SSL_CTX_set_ssl_version(ctx,meth) + SSL_CTX * ctx + SSL_METHOD * meth + +#else + int SSL_CTX_set_ssl_version(ctx,meth) SSL_CTX * ctx const SSL_METHOD * meth +#endif + long SSL_CTX_set_timeout(ctx,t) SSL_CTX * ctx diff --git a/typemap b/typemap index 5734b4f..3af0c5a 100644 --- a/typemap +++ b/typemap @@ -1,4 +1,5 @@ TYPEMAP +SSL_METHOD * T_PTR const SSL_METHOD * T_PTR SSL_CTX * T_PTR SSL_SESSION * T_PTR -- 1.7.5.4
Download (untitled) / with headers
text/plain 580b
Hi Douglas, nearly there, only one warning when I compile against OpenSSL-0.9.8i: SSLeay.c: In function ‘XS_Net__SSLeay_CIPHER_description’: SSLeay.c:5386: warning: passing argument 1 of ‘SSL_CIPHER_description’ discards qualifiers from pointer target type Cheers. On Sat Sep 24 03:18:17 2011, DOUGDUDE wrote: Show quoted text
> Ok. The reason those warnings popped up is because 2 methods before > 1.0.0 took an SSL_METHOD pointer not as a const while in 1.0.0 they
are Show quoted text
> const. I've attached a patch that chooses the correct signature.
This is Show quoted text
> tested against 1.0.0 and 0.9.8q.
Download (untitled) / with headers
text/plain 424b
On Sat Sep 24 03:29:46 2011, MIKEM wrote: Show quoted text
> Hi Douglas, > > nearly there, only one warning when I compile against OpenSSL-0.9.8i: > > SSLeay.c: In function ‘XS_Net__SSLeay_CIPHER_description’: > SSLeay.c:5386: warning: passing argument 1 of ‘SSL_CIPHER_description’ > discards qualifiers from pointer target type > > Cheers. >
Looks like SSL_CIPHER_description added const in 0.9.8k. Here is a patch for that.
Subject: 0005-Fix-a-function-signature-for-0.9.8k.patch
From c7d901123eb6dd2a336bab39193d41445c0b5d0b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson <doug@somethingdoug.com> Date: Sat, 24 Sep 2011 04:20:02 -0400 Subject: [PATCH] Fix a function signature for < 0.9.8k --- SSLeay.xs | 12 ++++++++++++ typemap | 1 + 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/SSLeay.xs b/SSLeay.xs index a041ca6..cbf4b5f 100644 --- a/SSLeay.xs +++ b/SSLeay.xs @@ -2054,12 +2054,24 @@ int SSL_check_private_key(ctx) SSL * ctx +#if OPENSSL_VERSION_NUMBER < 0x009080bfL + +char * +SSL_CIPHER_description(cipher,buf,size) + SSL_CIPHER * cipher + char * buf + int size + +#else + char * SSL_CIPHER_description(cipher,buf,size) const SSL_CIPHER * cipher char * buf int size +#endif + int SSL_CIPHER_get_bits(c,alg_bits) const SSL_CIPHER * c diff --git a/typemap b/typemap index 3af0c5a..270deb0 100644 --- a/typemap +++ b/typemap @@ -28,6 +28,7 @@ const unsigned char * T_PV CRYPTO_EX_new * T_PTR CRYPTO_EX_dup * T_PTR CRYPTO_EX_free * T_PTR +SSL_CIPHER * T_PTR const SSL_CIPHER * T_PTR int * T_PTR COMP_METHOD * T_PTR -- 1.7.6.msysgit.0
Download (untitled) / with headers
text/plain 600b
Nice work Douglas, no more warnings on 0.9.8i On Sat Sep 24 04:21:21 2011, . Ill push out a new release tomorrow. Cheers. DOUGDUDE wrote: Show quoted text
> On Sat Sep 24 03:29:46 2011, MIKEM wrote:
> > Hi Douglas, > > > > nearly there, only one warning when I compile against
OpenSSL-0.9.8i: Show quoted text
> > > > SSLeay.c: In function ‘XS_Net__SSLeay_CIPHER_description’: > > SSLeay.c:5386: warning: passing argument 1
of ‘SSL_CIPHER_description’ Show quoted text
> > discards qualifiers from pointer target type > > > > Cheers. > >
> > Looks like SSL_CIPHER_description added const in 0.9.8k. Here is a
patch Show quoted text
> for that.
Download (untitled) / with headers
text/plain 837b
Hi Douglas, OK, now have clean compiles with 0.9.8a through to 1.0.0. Thanks! New version 1.41 has been uploaded to CPAN. Cheers. On Sat Sep 24 06:32:44 2011, MIKEM wrote: Show quoted text
> Nice work Douglas, > > no more warnings on 0.9.8i > On Sat Sep 24 04:21:21 2011, . > > Ill push out a new release tomorrow. > > Cheers. > > > DOUGDUDE wrote:
> > On Sat Sep 24 03:29:46 2011, MIKEM wrote:
> > > Hi Douglas, > > > > > > nearly there, only one warning when I compile against
> OpenSSL-0.9.8i:
> > > > > > SSLeay.c: In function ‘XS_Net__SSLeay_CIPHER_description’: > > > SSLeay.c:5386: warning: passing argument 1
> of ‘SSL_CIPHER_description’
> > > discards qualifiers from pointer target type > > > > > > Cheers. > > >
> > > > Looks like SSL_CIPHER_description added const in 0.9.8k. Here is a
> patch
> > for that.
> >


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.