mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-07 06:42:56 +03:00
Merge remote-tracking branch 'rich/platform' into development
* rich/platform: Remove dependency on sscanf in lib x509 Fix extra guard in memory_buffer_alloc rebase from development implemented macro overriding for polarssl_* library functions fix bug introduced by the addition of snprintf and assert macro which caused tests to fail without polarssl_platform_c defined add initial symbols to config and checks to check_config to allow use of macros to define standard functions reformat and arrange additions to config alphabetically add missing checks to check_config add macro definition of assert using polarssl_exit modify library/memory_buffer_alloc.c, benchmark.c and the tests main code to use polarssl_exit add POLARSSL_PLATFORM_EXIT_ALT modify scripts/* and tests/* to use polarssl_snprintf modify programs/*.c to use polarssl_snprintf modify library/debug.c to use polarssl_snprintf modify library/x509*.c to use polarssl_snprintf modify library/net.c to use polarssl_snprintf modify oid.c to use polarssl_snprintf add platform_set_snprintf Conflicts: library/memory_buffer_alloc.c programs/pkey/pk_sign.c programs/pkey/pk_verify.c programs/pkey/rsa_sign_pss.c programs/pkey/rsa_verify_pss.c programs/ssl/ssl_client2.c programs/ssl/ssl_pthread_server.c programs/test/benchmark.c programs/test/ssl_cert_test.c
This commit is contained in:
@@ -6,6 +6,10 @@
|
||||
#define polarssl_fprintf fprintf
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#define polarssl_exit exit
|
||||
#define polarssl_fprintf fprintf
|
||||
#define polarssl_printf printf
|
||||
#define polarssl_snprintf snprintf
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
@@ -15,10 +19,17 @@ typedef UINT32 uint32_t;
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define assert(a) if( !( a ) ) \
|
||||
{ \
|
||||
polarssl_fprintf( stderr, "Assertion Failed at %s:%d - %s\n", \
|
||||
__FILE__, __LINE__, #a ); \
|
||||
polarssl_exit( 1 ); \
|
||||
}
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (big endian)
|
||||
*/
|
||||
@@ -42,13 +53,13 @@ typedef UINT32 uint32_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int unhexify(unsigned char *obuf, const char *ibuf)
|
||||
static int unhexify( unsigned char *obuf, const char *ibuf )
|
||||
{
|
||||
unsigned char c, c2;
|
||||
int len = strlen(ibuf) / 2;
|
||||
assert( strlen(ibuf) % 2 == 0 ); // must be even number of bytes
|
||||
int len = strlen( ibuf ) / 2;
|
||||
assert( strlen( ibuf ) % 2 == 0 ); // must be even number of bytes
|
||||
|
||||
while (*ibuf != 0)
|
||||
while( *ibuf != 0 )
|
||||
{
|
||||
c = *ibuf++;
|
||||
if( c >= '0' && c <= '9' )
|
||||
|
@@ -1,3 +1,15 @@
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#define polarssl_exit exit
|
||||
#define polarssl_free free
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_fprintf fprintf
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
|
||||
#include "polarssl/memory_buffer_alloc.h"
|
||||
#endif
|
||||
@@ -268,7 +280,7 @@ int main()
|
||||
{
|
||||
polarssl_fprintf( stderr, "FAILED: FATAL PARSE ERROR\n" );
|
||||
fclose(file);
|
||||
exit( 2 );
|
||||
polarssl_exit( 2 );
|
||||
}
|
||||
else
|
||||
total_errors++;
|
||||
|
@@ -17,10 +17,10 @@ void check_compiletime_version( char *version_str )
|
||||
memset( build_str, 0, 100 );
|
||||
memset( build_str_full, 0, 100 );
|
||||
|
||||
snprintf (build_str, 100, "%d.%d.%d", POLARSSL_VERSION_MAJOR,
|
||||
polarssl_snprintf( build_str, 100, "%d.%d.%d", POLARSSL_VERSION_MAJOR,
|
||||
POLARSSL_VERSION_MINOR, POLARSSL_VERSION_PATCH );
|
||||
|
||||
snprintf( build_str_full, 100, "mbed TLS %d.%d.%d", POLARSSL_VERSION_MAJOR,
|
||||
polarssl_snprintf( build_str_full, 100, "mbed TLS %d.%d.%d", POLARSSL_VERSION_MAJOR,
|
||||
POLARSSL_VERSION_MINOR, POLARSSL_VERSION_PATCH );
|
||||
|
||||
build_int = POLARSSL_VERSION_MAJOR << 24 |
|
||||
@@ -52,11 +52,11 @@ void check_runtime_version( char *version_str )
|
||||
version_get_string( get_str );
|
||||
version_get_string_full( get_str_full );
|
||||
|
||||
snprintf( build_str, 100, "%d.%d.%d",
|
||||
polarssl_snprintf( build_str, 100, "%d.%d.%d",
|
||||
(get_int >> 24) & 0xFF,
|
||||
(get_int >> 16) & 0xFF,
|
||||
(get_int >> 8) & 0xFF );
|
||||
snprintf( build_str_full, 100, "mbed TLS %s", version_str );
|
||||
polarssl_snprintf( build_str_full, 100, "mbed TLS %s", version_str );
|
||||
|
||||
TEST_ASSERT( strcmp( build_str, version_str ) == 0 );
|
||||
TEST_ASSERT( strcmp( build_str_full, get_str_full ) == 0 );
|
||||
|
Reference in New Issue
Block a user