Merge branch 'mbedtls-1.3' into development

* mbedtls-1.3:
  Fix compile errors with NO_STD_FUNCTIONS
  Expand config.pl's notion of "full"
  Ack external bugfix in Changelog
  FIx misplaced Changelog entry (oops)
  Fix compile bug: incompatible declaration of polarssl_exit in platform.c
  Fix contributor's name in Changelog
diff --git a/ChangeLog b/ChangeLog
index 9144451..1d995c8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -193,6 +193,10 @@
      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).
    * 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
@@ -285,8 +289,6 @@
      ciphersuite/certificate.
 
 Bugfix
-   * Fix bug in entropy.c when THREADING_C is also enabled that caused
-     entropy_free() to crash (found and fixed by ptahpeteh).
    * 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
diff --git a/include/mbedtls/platform.h b/include/mbedtls/platform.h
index aa97d8d..b71a09c 100644
--- a/include/mbedtls/platform.h
+++ b/include/mbedtls/platform.h
@@ -80,6 +80,8 @@
 #define mbedtls_free       MBEDTLS_PLATFORM_FREE_MACRO
 #define mbedtls_calloc     MBEDTLS_PLATFORM_CALLOC_MACRO
 #else
+/* For size_t */
+#include <stddef.h>
 extern void * (*mbedtls_calloc)( size_t n, size_t size );
 extern void (*mbedtls_free)( void *ptr );
 
@@ -103,6 +105,8 @@
  * The function pointers for fprintf
  */
 #if defined(MBEDTLS_PLATFORM_FPRINTF_ALT)
+/* We need FILE * */
+#include <stdio.h>
 extern int (*mbedtls_fprintf)( FILE *stream, const char *format, ... );
 
 /**
diff --git a/library/platform.c b/library/platform.c
index e9ab302..123267a 100644
--- a/library/platform.c
+++ b/library/platform.c
@@ -73,7 +73,7 @@
 {
     ((void) s);
     ((void) n);
-    ((void) format)
+    ((void) format);
     return( 0 );
 }
 
@@ -149,13 +149,12 @@
 static void platform_exit_uninit( int status )
 {
     ((void) status);
-    return( 0 );
 }
 
 #define MBEDTLS_PLATFORM_STD_EXIT   platform_exit_uninit
 #endif /* !MBEDTLS_PLATFORM_STD_EXIT */
 
-int (*mbedtls_exit)( int status ) = MBEDTLS_PLATFORM_STD_EXIT;
+void (*mbedtls_exit)( int status ) = MBEDTLS_PLATFORM_STD_EXIT;
 
 int mbedtls_platform_set_exit( void (*exit_func)( int status ) )
 {
diff --git a/scripts/config.pl b/scripts/config.pl
index 7d6c4ea..2685b4e 100755
--- a/scripts/config.pl
+++ b/scripts/config.pl
@@ -35,6 +35,11 @@
 _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/mbedtls/config.h";
 
 # get -f option
@@ -75,6 +80,7 @@
 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";
 
@@ -85,10 +91,12 @@
             $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!^//\s?!!;
         }
-        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") {
diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh
index 85eac01..e4da7b6 100755
--- a/tests/scripts/all.sh
+++ b/tests/scripts/all.sh
@@ -152,6 +152,14 @@
 scripts/config.pl unset MBEDTLS_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 MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
+CC=gcc CFLAGS='-Werror -O0' make
+
 msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
 cleanup
 cp "$CONFIG_H" "$CONFIG_BAK"