Prevent possible alignment warnings on casting from char * to 'aligned *'

This commit is contained in:
Paul Bakker 2013-10-28 12:57:08 +01:00
parent 677377f472
commit 45a2c8d99a
3 changed files with 17 additions and 33 deletions

View File

@ -3,6 +3,7 @@ PolarSSL ChangeLog (Sorted per branch, date)
= PolarSSL 1.3 branch = PolarSSL 1.3 branch
Bugfix Bugfix
* Server does not send out extensions not advertised by client * 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 = PolarSSL 1.3.1 released on 2013-10-15
Features Features

View File

@ -47,9 +47,22 @@
* Macro to generate an internal function for oid_XXX_from_asn1() (used by * Macro to generate an internal function for oid_XXX_from_asn1() (used by
* the other functions) * the other functions)
*/ */
#define FN_OID_TYPED_FROM_ASN1( TYPE_T, NAME, LIST ) \ #define FN_OID_TYPED_FROM_ASN1( TYPE_T, NAME, LIST ) \
static const TYPE_T * oid_ ## NAME ## _from_asn1( const asn1_buf *oid ) \ 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 ); } { \
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 * 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 ); \ 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 * For X520 attribute types
*/ */

View File

@ -74,8 +74,6 @@ static int ssl_save_session( const ssl_session *session,
left -= sizeof( ssl_session ); left -= sizeof( ssl_session );
#if defined(POLARSSL_X509_CRT_PARSE_C) #if defined(POLARSSL_X509_CRT_PARSE_C)
((ssl_session *) buf)->peer_cert = NULL;
if( session->peer_cert == NULL ) if( session->peer_cert == NULL )
cert_len = 0; cert_len = 0;
else else