summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2007-09-07 13:25:15 +0000
committerDr. Stephen Henson <steve@openssl.org>2007-09-07 13:25:15 +0000
commita6fbcb42209e2818c3d479da07aa71a7c1b2dd1a (patch)
tree01e8f25a0e28a70b861cec21bafb92e1deb6d91a /crypto
parent8164032a2e34ac236775cfcf6301d7c74534bbe4 (diff)
Change safestack reimplementation to match 0.9.8.
Fix additional gcc 4.2 value not used warnings.
Diffstat (limited to 'crypto')
-rw-r--r--crypto/asn1/x_crl.c2
-rw-r--r--crypto/conf/conf_api.c2
-rw-r--r--crypto/conf/conf_mod.c2
-rw-r--r--crypto/engine/eng_table.c4
-rw-r--r--crypto/stack/safestack.h168
-rw-r--r--crypto/x509/x509_vfy.c2
-rw-r--r--crypto/x509/x509_vpm.c2
-rw-r--r--crypto/x509v3/pcy_tree.c4
8 files changed, 58 insertions, 128 deletions
diff --git a/crypto/asn1/x_crl.c b/crypto/asn1/x_crl.c
index 5fed086438..d7093df9da 100644
--- a/crypto/asn1/x_crl.c
+++ b/crypto/asn1/x_crl.c
@@ -102,7 +102,7 @@ static int crl_inf_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
* would affect the output of X509_CRL_print().
*/
case ASN1_OP_D2I_POST:
- sk_X509_REVOKED_set_cmp_func(a->revoked,X509_REVOKED_cmp);
+ (void)sk_X509_REVOKED_set_cmp_func(a->revoked,X509_REVOKED_cmp);
break;
}
return 1;
diff --git a/crypto/conf/conf_api.c b/crypto/conf/conf_api.c
index a708235834..599ab25378 100644
--- a/crypto/conf/conf_api.c
+++ b/crypto/conf/conf_api.c
@@ -121,7 +121,7 @@ int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value)
v = (CONF_VALUE *)lh_insert(conf->data, value);
if (v != NULL)
{
- sk_CONF_VALUE_delete_ptr(ts,v);
+ (void)sk_CONF_VALUE_delete_ptr(ts,v);
OPENSSL_free(v->name);
OPENSSL_free(v->value);
OPENSSL_free(v);
diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c
index e40cc50dd6..bd0e0aad4d 100644
--- a/crypto/conf/conf_mod.c
+++ b/crypto/conf/conf_mod.c
@@ -432,7 +432,7 @@ void CONF_modules_unload(int all)
if (((md->links > 0) || !md->dso) && !all)
continue;
/* Since we're working in reverse this is OK */
- sk_CONF_MODULE_delete(supported_modules, i);
+ (void)sk_CONF_MODULE_delete(supported_modules, i);
module_free(md);
}
if (sk_CONF_MODULE_num(supported_modules) == 0)
diff --git a/crypto/engine/eng_table.c b/crypto/engine/eng_table.c
index a83c3899ee..0c1656168d 100644
--- a/crypto/engine/eng_table.c
+++ b/crypto/engine/eng_table.c
@@ -147,7 +147,7 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
lh_insert(&(*table)->piles, fnd);
}
/* A registration shouldn't add duplciate entries */
- sk_ENGINE_delete_ptr(fnd->sk, e);
+ (void)sk_ENGINE_delete_ptr(fnd->sk, e);
/* if 'setdefault', this ENGINE goes to the head of the list */
if(!sk_ENGINE_push(fnd->sk, e))
goto end;
@@ -178,7 +178,7 @@ static void int_unregister_cb(ENGINE_PILE *pile, ENGINE *e)
/* Iterate the 'c->sk' stack removing any occurance of 'e' */
while((n = sk_ENGINE_find(pile->sk, e)) >= 0)
{
- sk_ENGINE_delete(pile->sk, n);
+ (void)sk_ENGINE_delete(pile->sk, n);
/* "touch" this ENGINE_CIPHER */
pile->uptodate = 1;
}
diff --git a/crypto/stack/safestack.h b/crypto/stack/safestack.h
index 5810bca1e9..250929bf7d 100644
--- a/crypto/stack/safestack.h
+++ b/crypto/stack/safestack.h
@@ -1,5 +1,5 @@
/* ====================================================================
- * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved.
+ * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -57,80 +57,19 @@
#include <openssl/stack.h>
-#ifndef OPENSSL_ALLOW_FCAST
-
-#ifndef OPENSSL_INLINE
-# if defined(__SUNPRO_C) && !defined(__inline)
-# if __SUNPRO_C>0x520
-# define __inline inline
-# else
-# define __inline
-# endif
-# endif
-# define OPENSSL_INLINE __inline static
-#endif
-
-#define STACK_OF(type) struct stack_st_##type
-
-#define IMPLEMENT_STACK_OF(type) /* nada (obsolete in new safestack approach)*/
-
-#define DECLARE_STACK_OF(type) \
-STACK_OF(type) \
- { \
- STACK stack; \
- }; \
-OPENSSL_INLINE STACK_OF(type) *sk_##type##_new( \
- int (*cmp)(const type * const *, const type *const *)) \
- { return (STACK_OF(type) *)sk_new((int (*)(const char * const *, const char * const *))cmp); } \
-OPENSSL_INLINE STACK_OF(type) *sk_##type##_new_null(void) \
- { return (STACK_OF(type) *)sk_new_null(); } \
-OPENSSL_INLINE void sk_##type##_free(STACK_OF(type) *sk) \
- { sk_free((STACK *)sk); } \
-OPENSSL_INLINE int sk_##type##_num(const STACK_OF(type) *sk) \
- { return M_sk_num((const STACK *)sk); } \
-OPENSSL_INLINE type *sk_##type##_value(const STACK_OF(type) *sk,int n) \
- { return (type *)sk_value((STACK *)sk,n); } \
-OPENSSL_INLINE type *sk_##type##_set(STACK_OF(type) *sk,int n,type *v) \
- { return (type *)(sk_set((STACK *)sk,n,(char *)v)); } \
-OPENSSL_INLINE void sk_##type##_zero(STACK_OF(type) *sk) \
- { sk_zero((STACK *)sk); } \
-OPENSSL_INLINE int sk_##type##_push(STACK_OF(type) *sk,type *v) \
- { return sk_push((STACK *)sk,(char *)v); } \
-OPENSSL_INLINE int sk_##type##_unshift(STACK_OF(type) *sk,type *v) \
- { return sk_unshift((STACK *)sk,(char *)v); } \
-OPENSSL_INLINE int sk_##type##_find(STACK_OF(type) *sk,type *v) \
- { return sk_find((STACK *)sk,(char *)v); } \
-OPENSSL_INLINE type *sk_##type##_delete(STACK_OF(type) *sk,int n) \
- { return (type *)sk_delete((STACK *)sk,n); } \
-OPENSSL_INLINE void sk_##type##_delete_ptr(STACK_OF(type) *sk,type *v) \
- { sk_delete_ptr((STACK *)sk,(char *)v); } \
-OPENSSL_INLINE int sk_##type##_insert(STACK_OF(type) *sk,type *v,int n) \
- { return sk_insert((STACK *)sk,(char *)v,n); } \
-OPENSSL_INLINE int (*sk_##type##_set_cmp_func(STACK_OF(type) *sk, \
- int (*cmp)(const type * const *,const type * const *))) \
- (const type *const *,const type *const *) \
- { return (int (*)(const type * const *,const type *const *)) \
- sk_set_cmp_func((STACK *)sk,(int(*)(const char * const *, const char * const *))cmp); } \
-OPENSSL_INLINE STACK_OF(type) *sk_##type##_dup(STACK_OF(type) *sk) \
- { return (STACK_OF(type) *)sk_dup((STACK *)sk); } \
-OPENSSL_INLINE void sk_##type##_pop_free(STACK_OF(type) *sk,void (*func)(type *)) \
- { sk_pop_free((STACK *)sk,(void (*)(void *))func); } \
-OPENSSL_INLINE type *sk_##type##_shift(STACK_OF(type) *sk) \
- { return (type *)sk_shift((STACK *)sk); } \
-OPENSSL_INLINE type *sk_##type##_pop(STACK_OF(type) *sk) \
- { return (type *)sk_pop((STACK *)sk); } \
-OPENSSL_INLINE void sk_##type##_sort(STACK_OF(type) *sk) \
- { sk_sort((STACK *)sk); } \
-OPENSSL_INLINE int sk_##type##_is_sorted(const STACK_OF(type) *sk) \
- { return sk_is_sorted((const STACK *)sk); }
-
+#ifdef DEBUG_SAFESTACK
-#else
+#ifndef CHECKED_PTR_OF
+#define CHECKED_PTR_OF(type, p) \
+ ((void*) (1 ? p : (type*)0))
+#endif
-typedef void (*openssl_fptr)(void);
-#define openssl_fcast(f) ((openssl_fptr)f)
+#define CHECKED_SK_FREE_FUNC(type, p) \
+ ((void (*)(void *)) ((1 ? p : (void (*)(type *))0)))
-#ifdef DEBUG_SAFESTACK
+#define CHECKED_SK_CMP_FUNC(type, p) \
+ ((int (*)(const char * const *, const char * const *)) \
+ ((1 ? p : (int (*)(const type * const *, const type * const *))0)))
#define STACK_OF(type) struct stack_st_##type
#define PREDECLARE_STACK_OF(type) STACK_OF(type);
@@ -146,76 +85,71 @@ STACK_OF(type) \
/* SKM_sk_... stack macros are internal to safestack.h:
* never use them directly, use sk_<type>_... instead */
#define SKM_sk_new(type, cmp) \
- ((STACK_OF(type) * (*)(int (*)(const type * const *, const type * const *)))openssl_fcast(sk_new))(cmp)
+ ((STACK_OF(type) *)sk_new(CHECKED_SK_CMP_FUNC(type, cmp)))
#define SKM_sk_new_null(type) \
- ((STACK_OF(type) * (*)(void))openssl_fcast(sk_new_null))()
+ ((STACK_OF(type) *)sk_new_null())
#define SKM_sk_free(type, st) \
- ((void (*)(STACK_OF(type) *))openssl_fcast(sk_free))(st)
+ sk_free(CHECKED_PTR_OF(STACK_OF(type), st))
#define SKM_sk_num(type, st) \
- ((int (*)(const STACK_OF(type) *))openssl_fcast(sk_num))(st)
+ sk_num(CHECKED_PTR_OF(STACK_OF(type), st))
#define SKM_sk_value(type, st,i) \
- ((type * (*)(const STACK_OF(type) *, int))openssl_fcast(sk_value))(st, i)
+ ((type *)sk_value(CHECKED_PTR_OF(STACK_OF(type), st), i))
#define SKM_sk_set(type, st,i,val) \
- ((type * (*)(STACK_OF(type) *, int, type *))openssl_fcast(sk_set))(st, i, val)
+ sk_set(CHECKED_PTR_OF(STACK_OF(type), st), i, CHECKED_PTR_OF(type, val))
#define SKM_sk_zero(type, st) \
- ((void (*)(STACK_OF(type) *))openssl_fcast(sk_zero))(st)
+ sk_zero(CHECKED_PTR_OF(STACK_OF(type), st))
#define SKM_sk_push(type, st,val) \
- ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_push))(st, val)
+ sk_push(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_PTR_OF(type, val))
#define SKM_sk_unshift(type, st,val) \
- ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_unshift))(st, val)
+ sk_unshift(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_PTR_OF(type, val))
#define SKM_sk_find(type, st,val) \
- ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_find))(st, val)
+ sk_find(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_PTR_OF(type, val))
#define SKM_sk_delete(type, st,i) \
- ((type * (*)(STACK_OF(type) *, int))openssl_fcast(sk_delete))(st, i)
+ (type *)sk_delete(CHECKED_PTR_OF(STACK_OF(type), st), i)
#define SKM_sk_delete_ptr(type, st,ptr) \
- ((type * (*)(STACK_OF(type) *, type *))openssl_fcast(sk_delete_ptr))(st, ptr)
+ (type *)sk_delete_ptr(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_PTR_OF(type, ptr))
#define SKM_sk_insert(type, st,val,i) \
- ((int (*)(STACK_OF(type) *, type *, int))openssl_fcast(sk_insert))(st, val, i)
+ sk_insert(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_PTR_OF(type, val), i)
#define SKM_sk_set_cmp_func(type, st,cmp) \
- ((int (*(*)(STACK_OF(type) *, int (*)(const type * const *, const type * const *))) \
- (const type * const *, const type * const *))openssl_fcast(sk_set_cmp_func))\
- (st, cmp)
+ ((int (*)(const type * const *,const type * const *)) \
+ sk_set_cmp_func(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_SK_CMP_FUNC(type, cmp)))
#define SKM_sk_dup(type, st) \
- ((STACK_OF(type) *(*)(STACK_OF(type) *))openssl_fcast(sk_dup))(st)
+ (STACK_OF(type) *)sk_dup(CHECKED_PTR_OF(STACK_OF(type), st))
#define SKM_sk_pop_free(type, st,free_func) \
- ((void (*)(STACK_OF(type) *, void (*)(type *)))openssl_fcast(sk_pop_free))\
- (st, free_func)
+ sk_pop_free(CHECKED_PTR_OF(STACK_OF(type), st), CHECKED_SK_FREE_FUNC(type, free_func))
#define SKM_sk_shift(type, st) \
- ((type * (*)(STACK_OF(type) *))openssl_fcast(sk_shift))(st)
+ (type *)sk_shift(CHECKED_PTR_OF(STACK_OF(type), st))
#define SKM_sk_pop(type, st) \
- ((type * (*)(STACK_OF(type) *))openssl_fcast(sk_pop))(st)
+ (type *)sk_pop(CHECKED_PTR_OF(STACK_OF(type), st))
#define SKM_sk_sort(type, st) \
- ((void (*)(STACK_OF(type) *))openssl_fcast(sk_sort))(st)
+ sk_sort(CHECKED_PTR_OF(STACK_OF(type), st))
#define SKM_sk_is_sorted(type, st) \
- ((int (*)(const STACK_OF(type) *))openssl_fcast(sk_is_sorted))(st)
+ sk_is_sorted(CHECKED_PTR_OF(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) * (*) (STACK_OF(type) **,const unsigned char **, long , \
- type *(*)(type **, const unsigned char **,long), \
- void (*)(type *), int ,int )) openssl_fcast(d2i_ASN1_SET)) \
- (st,pp,length, d2i_func, free_func, ex_tag,ex_class)
+ (STACK_OF(type) *)d2i_ASN1_SET(CHECKED_PTR_OF(STACK_OF(type), st), \
+ pp, length, \
+ CHECKED_D2I_OF(type, d2i_func), \
+ CHECKED_SK_FREE_FUNC(type, free_func), \
+ ex_tag, ex_class)
+
#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \
- ((int (*)(STACK_OF(type) *,unsigned char **, \
- int (*)(type *,unsigned char **), int , int , int)) openssl_fcast(i2d_ASN1_SET)) \
- (st,pp,i2d_func,ex_tag,ex_class,is_set)
+ i2d_ASN1_SET(CHECKED_PTR_OF(STACK_OF(type), st), pp, \
+ CHECKED_I2D_OF(type, i2d_func), \
+ ex_tag, ex_class, is_set)
#define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \
- ((unsigned char *(*)(STACK_OF(type) *, \
- int (*)(type *,unsigned char **), unsigned char **,int *)) openssl_fcast(ASN1_seq_pack)) \
- (st, i2d_func, buf, len)
+ ASN1_seq_pack(CHECKED_PTR_OF(STACK_OF(type), st), \
+ CHECKED_I2D_OF(type, i2d_func), buf, len)
+
#define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \
- ((STACK_OF(type) * (*)(const unsigned char *,int, \
- type *(*)(type **,const unsigned char **, long), \
- void (*)(type *)))openssl_fcast(ASN1_seq_unpack)) \
- (buf,len,d2i_func, free_func)
+ (STACK_OF(type) *)ASN1_seq_unpack(buf, len, CHECKED_D2I_OF(type, d2i_func), CHECKED_SK_FREE_FUNC(type, free_func))
#define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \
- ((STACK_OF(type) * (*)(X509_ALGOR *, \
- type *(*)(type **, const unsigned char **, long), \
- void (*)(type *), \
- const char *, int, \
- ASN1_STRING *, int))PKCS12_decrypt_d2i) \
- (algor,d2i_func,free_func,pass,passlen,oct,seq)
+ (STACK_OF(type) *)PKCS12_decrypt_d2i(algor, \
+ CHECKED_D2I_OF(type, d2i_func), \
+ CHECKED_SK_FREE_FUNC(type, free_func), \
+ pass, passlen, oct, seq)
#else
@@ -810,7 +744,6 @@ STACK_OF(type) \
#define sk_GENERAL_SUBTREE_sort(st) SKM_sk_sort(GENERAL_SUBTREE, (st))
#define sk_GENERAL_SUBTREE_is_sorted(st) SKM_sk_is_sorted(GENERAL_SUBTREE, (st))
-#ifndef OPENSSL_NO_RFC3779
#define sk_IPAddressFamily_new(st) SKM_sk_new(IPAddressFamily, (st))
#define sk_IPAddressFamily_new_null() SKM_sk_new_null(IPAddressFamily)
#define sk_IPAddressFamily_free(st) SKM_sk_free(IPAddressFamily, (st))
@@ -854,7 +787,6 @@ STACK_OF(type) \
#define sk_IPAddressOrRange_pop(st) SKM_sk_pop(IPAddressOrRange, (st))
#define sk_IPAddressOrRange_sort(st) SKM_sk_sort(IPAddressOrRange, (st))
#define sk_IPAddressOrRange_is_sorted(st) SKM_sk_is_sorted(IPAddressOrRange, (st))
-#endif /* OPENSSL_NO_RFC3779 */
#define sk_KRB5_APREQBODY_new(st) SKM_sk_new(KRB5_APREQBODY, (st))
#define sk_KRB5_APREQBODY_new_null() SKM_sk_new_null(KRB5_APREQBODY)
@@ -2056,6 +1988,4 @@ STACK_OF(type) \
SKM_PKCS12_decrypt_d2i(PKCS7, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))
/* End of util/mkstack.pl block, you may now edit :-) */
-#endif
-
#endif /* !defined HEADER_SAFESTACK_H */
diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c
index ba2c3836f5..609606c13e 100644
--- a/crypto/x509/x509_vfy.c
+++ b/crypto/x509/x509_vfy.c
@@ -166,7 +166,7 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
goto end;
}
CRYPTO_add(&xtmp->references,1,CRYPTO_LOCK_X509);
- sk_X509_delete_ptr(sktmp,xtmp);
+ (void)sk_X509_delete_ptr(sktmp,xtmp);
ctx->last_untrusted++;
x=xtmp;
num++;
diff --git a/crypto/x509/x509_vpm.c b/crypto/x509/x509_vpm.c
index 5e69259a79..e9db6d62a7 100644
--- a/crypto/x509/x509_vpm.c
+++ b/crypto/x509/x509_vpm.c
@@ -385,7 +385,7 @@ int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param)
{
ptmp = sk_X509_VERIFY_PARAM_value(param_table, idx);
X509_VERIFY_PARAM_free(ptmp);
- sk_X509_VERIFY_PARAM_delete(param_table, idx);
+ (void)sk_X509_VERIFY_PARAM_delete(param_table, idx);
}
}
if (!sk_X509_VERIFY_PARAM_push(param_table, param))
diff --git a/crypto/x509v3/pcy_tree.c b/crypto/x509v3/pcy_tree.c
index 27d29f25a8..4fda1d419a 100644
--- a/crypto/x509v3/pcy_tree.c
+++ b/crypto/x509v3/pcy_tree.c
@@ -345,7 +345,7 @@ static int tree_prune(X509_POLICY_TREE *tree, X509_POLICY_LEVEL *curr)
{
node->parent->nchild--;
OPENSSL_free(node);
- sk_X509_POLICY_NODE_delete(curr->nodes, i);
+ (void)sk_X509_POLICY_NODE_delete(curr->nodes, i);
}
}
@@ -358,7 +358,7 @@ static int tree_prune(X509_POLICY_TREE *tree, X509_POLICY_LEVEL *curr)
{
node->parent->nchild--;
OPENSSL_free(node);
- sk_X509_POLICY_NODE_delete(curr->nodes, i);
+ (void)sk_X509_POLICY_NODE_delete(curr->nodes, i);
}
}
if (curr->anyPolicy && !curr->anyPolicy->nchild)