Skip Menu |
 
Ticket metadata
The Basics
Id: 2123
Status: new
Priority: 0/
Queue: OpenSSL-Bugs

Custom Fields
Milestone: (no value)
Subsystem: (no value)
Severity: (no value)
Broken in: (no value)

People
Owner: Nobody in particular
Requestors: Mattias Ellert
Cc:
AdminCc:

New reminder:
Subject:
Owner:
Due:

Dates
Created: Thu Dec 03 20:56:44 2009
Starts: Not set
Started: Not set
Last Contact: Not set
Due: Not set
Closed: Not set
Updated: Thu Dec 03 20:56:45 2009 by Mattias Ellert



Subject: Buggy openssl header causes compilation errors
Date: Thu, 03 Dec 2009 12:23:04 +0100
To: rt@openssl.org
From: Mattias Ellert <mattias.ellert@fysast.uu.se>
Download (untitled) / with headers
text/plain 2.3k
Created from downstream bug report:

https://bugzilla.redhat.com/show_bug.cgi?id=543634


Description of problem:

The openssl/asn1.h header file is buggy. For a C program this causes compiler
warnings. For a C++ program this causes compiler errors, because C++ is a
strongly typed language.

Version-Release number of selected component (if applicable):

openssl-devel-1.0.0-0.13.beta4.fc12.x86_64

How reproducible:

Always.

Steps to Reproduce:

1. Compile the attatched test program:

https://bugzilla.redhat.com/attachment.cgi?id=375537

Actual results:

2. With gcc it compiles but gives warnings:

[ellert@localhost ~]$ LANG=C gcc -o test test.c -lssl
test.c: In function 'main':
test.c:12: warning: passing argument 1 of 'i2d_ASN1_SET' from incompatible
pointer type
/usr/include/openssl/asn1.h:894: note: expected 'struct stack_st_OPENSSL_BLOCK
*' but argument is of type 'struct _STACK *'
test.c:14: warning: passing argument 1 of 'i2d_ASN1_SET' from incompatible
pointer type
/usr/include/openssl/asn1.h:894: note: expected 'struct stack_st_OPENSSL_BLOCK
*' but argument is of type 'struct _STACK *'

3. With g++ it fails to compile, because the type mismatches are considered
errors:

[ellert@localhost ~]$ LANG=C g++ -o test test.c -lssl
test.c: In function 'int main()':
test.c:12: error: cannot convert '_STACK*' to 'stack_st_OPENSSL_BLOCK*' for
argument '1' to 'int i2d_ASN1_SET(stack_st_OPENSSL_BLOCK*, unsigned char**, int
(*)(void*, unsigned char**), int, int, int)'
test.c:14: error: cannot convert '_STACK*' to 'stack_st_OPENSSL_BLOCK*' for
argument '1' to 'int i2d_ASN1_SET(stack_st_OPENSSL_BLOCK*, unsigned char**, int
(*)(void*, unsigned char**), int, int, int)'

Expected results:

No warnings in C, working compilation in C++.

Additional info:

There are 4 macros in openssl/asn1.h which are defined using
STACK_OF(OPENSSL_BLOCK). However, by the time theses macros are being resolved
all the arguments have been put through the CHECKED_xxx macros and been
anonymized and are simply _STACK pointers. The 4 macros are:

i2d_ASN1_SET, d2i_ASN1_SET, ASN1_seq_unpack, and ASN1_seq_pack.



This is a rather clumsy workaround for the bug:

https://bugzilla.redhat.com/attachment.cgi?id=375568

This compiles without warnings/error for C and C++:

[ellert@localhost ~]$ gcc -o test test-wo.c -lssl
[ellert@localhost ~]$ g++ -o test test-wo.c -lssl
[ellert@localhost ~]$