From 45a2c8d99a3782885cc0f08da7473f9476aea3ec Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Mon, 28 Oct 2013 12:57:08 +0100 Subject: [PATCH] Prevent possible alignment warnings on casting from char * to 'aligned *' --- ChangeLog | 1 + library/oid.c | 47 ++++++++++++++++------------------------------- library/ssl_srv.c | 2 -- 3 files changed, 17 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0487932da..86f5fdacd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ PolarSSL ChangeLog (Sorted per branch, date) = PolarSSL 1.3 branch Bugfix * Server does not send out extensions not advertised by client + * Prevent possible alignment warnings on casting from char * to 'aligned *' = PolarSSL 1.3.1 released on 2013-10-15 Features diff --git a/library/oid.c b/library/oid.c index c9cfe4842..a4f2c0c2c 100644 --- a/library/oid.c +++ b/library/oid.c @@ -47,9 +47,22 @@ * Macro to generate an internal function for oid_XXX_from_asn1() (used by * the other functions) */ -#define FN_OID_TYPED_FROM_ASN1( TYPE_T, NAME, LIST ) \ -static const TYPE_T * oid_ ## NAME ## _from_asn1( const asn1_buf *oid ) \ -{ return (const TYPE_T *) oid_descriptor_from_buf(LIST, sizeof(TYPE_T), oid->p, oid->len ); } +#define FN_OID_TYPED_FROM_ASN1( TYPE_T, NAME, LIST ) \ +static const TYPE_T * oid_ ## NAME ## _from_asn1( const asn1_buf *oid ) \ +{ \ + const TYPE_T *p = LIST; \ + const oid_descriptor_t *cur = (const oid_descriptor_t *) p; \ + if( p == NULL || oid == NULL ) return( NULL ); \ + while( cur->asn1 != NULL ) { \ + if( cur->asn1_len == oid->len && \ + memcmp( cur->asn1, oid->p, oid->len ) == 0 ) { \ + return( p ); \ + } \ + p++; \ + cur = (const oid_descriptor_t *) p; \ + } \ + return( NULL ); \ +} /* * Macro to generate a function for retrieving a single attribute from the @@ -132,34 +145,6 @@ int FN_NAME( ATTR1_TYPE ATTR1, ATTR2_TYPE ATTR2, const char **oid , \ return( POLARSSL_ERR_OID_NOT_FOUND ); \ } -/* - * Core generic function - */ -static const oid_descriptor_t *oid_descriptor_from_buf( const void *struct_set, - size_t struct_size, const unsigned char *oid, size_t len ) -{ - const unsigned char *p = (const unsigned char *) struct_set; - const oid_descriptor_t *cur; - - if( struct_set == NULL || oid == NULL ) - return( NULL ); - - cur = (const oid_descriptor_t *) p; - while( cur->asn1 != NULL ) - { - if( cur->asn1_len == len && - memcmp( cur->asn1, oid, len ) == 0 ) - { - return( cur ); - } - - p += struct_size; - cur = (const oid_descriptor_t *) p; - } - - return( NULL ); -} - /* * For X520 attribute types */ diff --git a/library/ssl_srv.c b/library/ssl_srv.c index 9d5017541..42ff46732 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -74,8 +74,6 @@ static int ssl_save_session( const ssl_session *session, left -= sizeof( ssl_session ); #if defined(POLARSSL_X509_CRT_PARSE_C) - ((ssl_session *) buf)->peer_cert = NULL; - if( session->peer_cert == NULL ) cert_len = 0; else