Hi!
The attached test file does not compile:
$ gcc -o test.o -c test.c
test.c: In function 'd2i_X':
test.c:28: warning: pointer type mismatch in conditional expression
The problem can be tracked down to the SKM_ASN1_SET_OF_d2i in
safestack.h. If the macro is changed as in the attached patch the
compilation works.
Mattias
#include openssl/x509.h
#include openssl/asn1_mac.h
#include openssl/err.h
typedef struct X {
STACK_OF(X509_EXTENSION) *ext;
} X;
X *X_new() {
X* ret = NULL;
ASN1_CTX c;
M_ASN1_New_Malloc(ret, X);
M_ASN1_New(ret-ext, sk_X509_EXTENSION_new_null);
return(ret);
M_ASN1_New_Error(5018);
}
void X_free(X *x) {
if (!x) return;
sk_X509_EXTENSION_pop_free(x-ext, X509_EXTENSION_free);
OPENSSL_free(x);
}
X* d2i_X(X **x, const unsigned char **pp, long length) {
M_ASN1_D2I_vars(x, X*, X_new);
M_ASN1_D2I_Init();
M_ASN1_D2I_start_sequence();
M_ASN1_D2I_get_seq_opt_type(X509_EXTENSION, ret-ext, d2i_X509_EXTENSION, X509_EXTENSION_free);
M_ASN1_D2I_Finish(x, X_free, 5019);
}
--- /usr/include/openssl/safestack.h 2010-06-04 16:29:26.0 +0200
+++ include/openssl/safestack.h 2010-09-13 09:04:17.969550072 +0200
@@ -179,7 +179,7 @@
sk_is_sorted(CHECKED_STACK_OF(type, st))
#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
- (STACK_OF(type) *)d2i_ASN1_SET((STACK_OF(OPENSSL_BLOCK) **)CHECKED_STACK_OF(type, st), \
+ (STACK_OF(type) *)d2i_ASN1_SET((STACK_OF(OPENSSL_BLOCK) **)CHECKED_PTR_OF(STACK_OF(type)*, st), \
pp, length, \
CHECKED_D2I_OF(type, d2i_func), \
CHECKED_SK_FREE_FUNC(type, free_func), \
smime.p7s
Description: S/MIME cryptographic signature