From d22514e8f6f453284dd1cc23197d407c56ae127c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 2 Jun 2015 12:59:59 +0100 Subject: [PATCH 1/6] Fix contributor's name in Changelog --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 18876e5a2..b061da31e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -128,7 +128,7 @@ Features Bugfix * Fix bug in entropy.c when THREADING_C is also enabled that caused - entropy_free() to crash (found and fixed by ptahpeteh). + entropy_free() to crash (thanks to Rafał Przywara). * Stack buffer overflow if ctr_drbg_update() is called with too large add_len (found by Jean-Philippe Aumasson) (not triggerable remotely). * Possible buffer overflow of length at most POLARSSL_MEMORY_ALIGN_MULTIPLE From 249bece013013029ef305c8c7b78886eeb366f66 Mon Sep 17 00:00:00 2001 From: ptahpeteh Date: Tue, 2 Jun 2015 15:26:09 +0200 Subject: [PATCH 2/6] Fix compile bug: incompatible declaration of polarssl_exit in platform.c This causes a compile-time error: platform.c(157): error: #147: declaration is incompatible with "void (*polarssl_exit)(int)" (declared at line 179 of "platform.h") --- library/platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/platform.c b/library/platform.c index 4afe8b74b..96f2a9d96 100644 --- a/library/platform.c +++ b/library/platform.c @@ -154,7 +154,7 @@ static void platform_exit_uninit( int status ) #define POLARSSL_PLATFORM_STD_EXIT platform_exit_uninit #endif /* !POLARSSL_PLATFORM_STD_EXIT */ -int (*polarssl_exit)( int status ) = POLARSSL_PLATFORM_STD_EXIT; +void (*polarssl_exit)( int status ) = POLARSSL_PLATFORM_STD_EXIT; int platform_set_exit( void (*exit_func)( int status ) ) { From 3e87a9f57f5103403ac4323f6fb86a4ceb64fc8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 3 Jun 2015 09:48:26 +0100 Subject: [PATCH 3/6] FIx misplaced Changelog entry (oops) --- ChangeLog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b061da31e..2b5625ec1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,8 @@ Features errors on use of deprecated functions. Bugfix + * Fix bug in entropy.c when THREADING_C is also enabled that caused + entropy_free() to crash (thanks to Rafał Przywara). * Fix memory leak when gcm_setkey() and ccm_setkey() are used more than once on the same context. * Fix bug in ssl_mail_client when password is longer that username (found @@ -127,8 +129,6 @@ Features ciphersuite/certificate. Bugfix - * Fix bug in entropy.c when THREADING_C is also enabled that caused - entropy_free() to crash (thanks to Rafał Przywara). * Stack buffer overflow if ctr_drbg_update() is called with too large add_len (found by Jean-Philippe Aumasson) (not triggerable remotely). * Possible buffer overflow of length at most POLARSSL_MEMORY_ALIGN_MULTIPLE From f2ec505c34c53a1c26b06bfd0bd405c5865a61e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 3 Jun 2015 09:50:07 +0100 Subject: [PATCH 4/6] Ack external bugfix in Changelog --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 2b5625ec1..2582c9a46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,7 @@ Features errors on use of deprecated functions. Bugfix + * Fix compile error with PLATFORM_EXIT_ALT (thanks to Rafał Przywara). * Fix bug in entropy.c when THREADING_C is also enabled that caused entropy_free() to crash (thanks to Rafał Przywara). * Fix memory leak when gcm_setkey() and ccm_setkey() are used more than From b752715893ff78c2191e24e842fce677841cfebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 3 Jun 2015 09:59:06 +0100 Subject: [PATCH 5/6] Expand config.pl's notion of "full" Make sure bugs in PLATFORM_xxx_ALT are catched --- scripts/config.pl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/config.pl b/scripts/config.pl index c105a2321..6ee1345e9 100755 --- a/scripts/config.pl +++ b/scripts/config.pl @@ -36,6 +36,11 @@ POLARSSL_PKCS11_C _ALT\s*$ ); +# Things that should be enabled in "full" even if they match @excluded +my @non_excluded = qw( +PLATFORM_[A-Z0-9]+_ALT +); + my $config_file = "include/polarssl/config.h"; # get -f option @@ -76,6 +81,7 @@ my @config_lines = <$config_read>; close $config_read; my $exclude_re = join '|', @excluded; +my $no_exclude_re = join '|', @non_excluded; open my $config_write, '>', $config_file or die "write $config_file: $!\n"; @@ -86,7 +92,8 @@ for my $line (@config_lines) { $done = 1; } - if (!$done && $line =~ m!^//\s?#define! && $line !~ /$exclude_re/) { + if (!$done && $line =~ m!^//\s?#define! && + ( $line !~ /$exclude_re/ || $line =~ /$no_exclude_re/ ) ) { $line =~ s!^//!!; } } elsif ($action eq "unset") { From dccb80b7e55281fb0fba1c88c69baddc5d72e0ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 3 Jun 2015 10:20:33 +0100 Subject: [PATCH 6/6] Fix compile errors with NO_STD_FUNCTIONS --- ChangeLog | 1 + include/polarssl/platform.h | 4 ++++ library/platform.c | 3 +-- tests/scripts/all.sh | 8 ++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2582c9a46..aa02b5939 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,7 @@ Features errors on use of deprecated functions. Bugfix + * Fix compile errors with PLATFORM_NO_STD_FUNCTIONS. * Fix compile error with PLATFORM_EXIT_ALT (thanks to Rafał Przywara). * Fix bug in entropy.c when THREADING_C is also enabled that caused entropy_free() to crash (thanks to Rafał Przywara). diff --git a/include/polarssl/platform.h b/include/polarssl/platform.h index 9095203e0..639b180e3 100644 --- a/include/polarssl/platform.h +++ b/include/polarssl/platform.h @@ -85,6 +85,8 @@ extern "C" { #define polarssl_free POLARSSL_PLATFORM_FREE_MACRO #define polarssl_malloc POLARSSL_PLATFORM_MALLOC_MACRO #else +/* For size_t */ +#include extern void * (*polarssl_malloc)( size_t len ); extern void (*polarssl_free)( void *ptr ); @@ -108,6 +110,8 @@ int platform_set_malloc_free( void * (*malloc_func)( size_t ), * The function pointers for fprintf */ #if defined(POLARSSL_PLATFORM_FPRINTF_ALT) +/* We need FILE * */ +#include extern int (*polarssl_fprintf)( FILE *stream, const char *format, ... ); /** diff --git a/library/platform.c b/library/platform.c index 96f2a9d96..a36dc62ab 100644 --- a/library/platform.c +++ b/library/platform.c @@ -72,7 +72,7 @@ static int platform_snprintf_uninit( char * s, size_t n, { ((void) s); ((void) n); - ((void) format) + ((void) format); return( 0 ); } @@ -148,7 +148,6 @@ int platform_set_fprintf( int (*fprintf_func)( FILE *, const char *, ... ) ) static void platform_exit_uninit( int status ) { ((void) status); - return( 0 ); } #define POLARSSL_PLATFORM_STD_EXIT platform_exit_uninit diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index c083924b7..41993d95a 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -146,6 +146,14 @@ scripts/config.pl unset POLARSSL_MEMORY_BUFFER_ALLOC_C scripts/config.pl unset POLARSSL_FS_IO CC=gcc CFLAGS='-Werror -O0' make +# catch compile bugs in _uninit functions +msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s +cleanup +cp "$CONFIG_H" "$CONFIG_BAK" +scripts/config.pl full +scripts/config.pl set POLARSSL_PLATFORM_NO_STD_FUNCTIONS +CC=gcc CFLAGS='-Werror -O0' make + if uname -a | grep -F x86_64 >/dev/null; then msg "build: i386, make, gcc" # ~ 30s cleanup