Skip to content

Commit

Permalink
mbedtls: do not include time.h without MBEDTLS_HAVE_TIME
Browse files Browse the repository at this point in the history
MBEDTLS_HAVE_TIME is documented as: "System has time.h and time()."

If that is not defined, do not attempt to include time.h.

A particular problem is platform-time.h, which should only be included if
MBEDTLS_HAVE_TIME is defined, which makes everything messier. Maybe it
should be refactored to have the check inside the header.

Signed-off-by: Daniel Axtens <[email protected]>
  • Loading branch information
daxtens committed May 24, 2021
1 parent 1e75ed7 commit 23126e9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/mbedtls/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ extern "C" {
#if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS)
#include <stdio.h>
#include <stdlib.h>
#if defined(MBEDTLS_HAVE_TIME)
#include <time.h>
#endif
#if !defined(MBEDTLS_PLATFORM_STD_SNPRINTF)
#if defined(_WIN32)
#define MBEDTLS_PLATFORM_STD_SNPRINTF mbedtls_platform_win32_snprintf /**< The default \c snprintf function to use. */
Expand Down
2 changes: 2 additions & 0 deletions library/x509_crl.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@
#define mbedtls_snprintf snprintf
#endif

#if defined(MBEDTLS_HAVE_TIME)
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
#include <windows.h>
#else
#include <time.h>
#endif
#endif

#if defined(MBEDTLS_FS_IO) || defined(EFIX64) || defined(EFI32)
#include <stdio.h>
Expand Down
2 changes: 2 additions & 0 deletions library/x509_crt.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@
#include "mbedtls/threading.h"
#endif

#if defined(MBEDTLS_HAVE_TIME)
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
#include <windows.h>
#else
#include <time.h>
#endif
#endif

#if defined(MBEDTLS_FS_IO)
#include <stdio.h>
Expand Down
2 changes: 2 additions & 0 deletions programs/ssl/query_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@
#include "mbedtls/pkcs11.h"
#include "mbedtls/pkcs12.h"
#include "mbedtls/pkcs5.h"
#if defined(MBEDTLS_HAVE_TIME)
#include "mbedtls/platform_time.h"
#endif
#include "mbedtls/platform_util.h"
#include "mbedtls/poly1305.h"
#include "mbedtls/ripemd160.h"
Expand Down
2 changes: 2 additions & 0 deletions scripts/data_files/query_config.fmt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@
#include "mbedtls/pkcs11.h"
#include "mbedtls/pkcs12.h"
#include "mbedtls/pkcs5.h"
#if defined(MBEDTLS_HAVE_TIME)
#include "mbedtls/platform_time.h"
#endif
#include "mbedtls/platform_util.h"
#include "mbedtls/poly1305.h"
#include "mbedtls/ripemd160.h"
Expand Down

0 comments on commit 23126e9

Please sign in to comment.