Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add limits.h inclusion to ssl_tls.c and udp_proxy.c #1999

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 3rdparty/everest/library/Hacl_Curve25519_joined.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I've stated before, I don't like this approach. Every library source file is changed to include something that doesn't really concern it.

Furthermore this is unrelated to the original objective of the pull request. It neither fixes the problem nor contributes to making the problem less likely to happen again.

I wouldn't have vetoed the PR on this basis, but since the PR needs rework anyway, please remove the inclusion of check_config.h everywhere.

To include check_config.h everywhere, on development, add it to library/common.h, which was added to development today (and we'll also need to include common.h everywhere, which isn't done yet).


#if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED)

Expand Down
1 change: 1 addition & 0 deletions 3rdparty/everest/library/everest.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#include <string.h>

Expand Down
1 change: 1 addition & 0 deletions 3rdparty/everest/library/x25519.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_ECDH_C) && defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED)

Expand Down
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Bugfix
a warning with some compilers. Fix contributed by irwir in #2856.
* Fix a function name in a debug message. Contributed by Ercan Ozturk in
#3013.
* Add missing limits.h standard C library header to ssl_tls.c and udp_proxy.c
which was only including it via check_config.h previously, which may not be
included in custom configuration files. Fixes #1803
Comment on lines +40 to +42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changelog entry would get added to the section for the already-released version 2.22.0. We no longer merge changelog entries manually. Please create a file in ChangeLog.d instead. This doesn't require a rebase.


Changes
* Mbed Crypto is no longer a Git submodule. The crypto part of the library
Expand Down
2 changes: 0 additions & 2 deletions configs/config-ccm-psk-tls1_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,4 @@
*/
#define MBEDTLS_SSL_MAX_CONTENT_LEN 1024

#include "mbedtls/check_config.h"

#endif /* MBEDTLS_CONFIG_H */
2 changes: 0 additions & 2 deletions configs/config-mini-tls1_1.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,4 @@
/* For testing with compat.sh */
#define MBEDTLS_FS_IO

#include "mbedtls/check_config.h"

#endif /* MBEDTLS_CONFIG_H */
2 changes: 0 additions & 2 deletions configs/config-no-entropy.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,4 @@
/* Miscellaneous options */
#define MBEDTLS_AES_ROM_TABLES

#include "mbedtls/check_config.h"

#endif /* MBEDTLS_CONFIG_H */
2 changes: 0 additions & 2 deletions configs/config-suite-b.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,4 @@
*/
#define MBEDTLS_SSL_MAX_CONTENT_LEN 1024

#include "mbedtls/check_config.h"

#endif /* MBEDTLS_CONFIG_H */
2 changes: 0 additions & 2 deletions configs/config-thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,4 @@
/* Save ROM and a few bytes of RAM by specifying our own ciphersuite list */
#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8

#include "mbedtls/check_config.h"

#endif /* MBEDTLS_CONFIG_H */
2 changes: 0 additions & 2 deletions include/mbedtls/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3688,6 +3688,4 @@
#include MBEDTLS_USER_CONFIG_FILE
#endif

#include "mbedtls/check_config.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's one place where check_config.h modifies the configuration.

#if defined(_WIN32)
#if !defined(MBEDTLS_PLATFORM_C)
#error "MBEDTLS_PLATFORM_C is required on Windows"
#endif

/* Fix the config here. Not convenient to put an #ifdef _WIN32 in config.h as
 * it would confuse config.py. */
#if !defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) && \
    !defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO)
#define MBEDTLS_PLATFORM_SNPRINTF_ALT
#endif

#if !defined(MBEDTLS_PLATFORM_VSNPRINTF_ALT) && \
    !defined(MBEDTLS_PLATFORM_VSNPRINTF_MACRO)
#define MBEDTLS_PLATFORM_VSNPRINTF_ALT
#endif
#endif /* _WIN32 */

If check_config.h is no longer included from config.h, and thus only included from library code and not from application code, this won't do. Application code and library code must have the same configuration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only code in the library that is functionally affected by MBEDTLS_PLATFORM_SNPRINTF_ALT or MBEDTLS_PLATFORM_VSNPRINTF_ALT is in platform.h and platform.c. Application code that is affected by these macros can be reasonably expected to include mbedtls/platform.h. Therefore I think this hack can be adapted to fit in platform.h instead.

Feature detection (version_features.c, query_config) would no longer report these alt symbols correctly. I think that an acceptable change would be to not set the symbols, but cause their effect in platform.h regardless.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fortunately, it turns out that changing the configuration is not necessary: platform.h will do its thing (activate an snprintf wrapper) regardless. #3453


#endif /* MBEDTLS_CONFIG_H */
1 change: 1 addition & 0 deletions library/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_AES_C)

Expand Down
1 change: 1 addition & 0 deletions library/aesni.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_AESNI_C)

Expand Down
1 change: 1 addition & 0 deletions library/arc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_ARC4_C)

Expand Down
1 change: 1 addition & 0 deletions library/aria.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_ARIA_C)

Expand Down
1 change: 1 addition & 0 deletions library/asn1parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_ASN1_PARSE_C)

Expand Down
1 change: 1 addition & 0 deletions library/asn1write.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_ASN1_WRITE_C)

Expand Down
1 change: 1 addition & 0 deletions library/base64.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_BASE64_C)

Expand Down
1 change: 1 addition & 0 deletions library/bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_BIGNUM_C)

Expand Down
1 change: 1 addition & 0 deletions library/blowfish.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_BLOWFISH_C)

Expand Down
1 change: 1 addition & 0 deletions library/camellia.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_CAMELLIA_C)

Expand Down
1 change: 1 addition & 0 deletions library/ccm.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_CCM_C)

Expand Down
1 change: 1 addition & 0 deletions library/certs.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#include "mbedtls/certs.h"

Expand Down
1 change: 1 addition & 0 deletions library/chacha20.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_CHACHA20_C)

Expand Down
1 change: 1 addition & 0 deletions library/chachapoly.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_CHACHAPOLY_C)

Expand Down
1 change: 1 addition & 0 deletions library/cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_CIPHER_C)

Expand Down
1 change: 1 addition & 0 deletions library/cipher_wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_CIPHER_C)

Expand Down
1 change: 1 addition & 0 deletions library/cmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_CMAC_C)

Expand Down
1 change: 1 addition & 0 deletions library/ctr_drbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_CTR_DRBG_C)

Expand Down
1 change: 1 addition & 0 deletions library/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_DEBUG_C)

Expand Down
1 change: 1 addition & 0 deletions library/des.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_DES_C)

Expand Down
1 change: 1 addition & 0 deletions library/dhm.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_DHM_C)

Expand Down
1 change: 1 addition & 0 deletions library/ecdh.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_ECDH_C)

Expand Down
1 change: 1 addition & 0 deletions library/ecdsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_ECDSA_C)

Expand Down
1 change: 1 addition & 0 deletions library/ecjpake.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_ECJPAKE_C)

Expand Down
1 change: 1 addition & 0 deletions library/ecp.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

/**
* \brief Function level alternative implementation.
Expand Down
1 change: 1 addition & 0 deletions library/ecp_curves.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_ECP_C)

Expand Down
1 change: 1 addition & 0 deletions library/entropy.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_ENTROPY_C)

Expand Down
1 change: 1 addition & 0 deletions library/entropy_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#include <string.h>

Expand Down
1 change: 1 addition & 0 deletions library/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_ERROR_STRERROR_DUMMY)
#include <string.h>
Expand Down
1 change: 1 addition & 0 deletions library/gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_GCM_C)

Expand Down
1 change: 1 addition & 0 deletions library/havege.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_HAVEGE_C)

Expand Down
1 change: 1 addition & 0 deletions library/hkdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_HKDF_C)

Expand Down
1 change: 1 addition & 0 deletions library/hmac_drbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_HMAC_DRBG_C)

Expand Down
1 change: 1 addition & 0 deletions library/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_MD_C)

Expand Down
1 change: 1 addition & 0 deletions library/md2.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_MD2_C)

Expand Down
1 change: 1 addition & 0 deletions library/md4.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_MD4_C)

Expand Down
1 change: 1 addition & 0 deletions library/md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_MD5_C)

Expand Down
1 change: 1 addition & 0 deletions library/memory_buffer_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
#include "mbedtls/memory_buffer_alloc.h"
Expand Down
1 change: 1 addition & 0 deletions library/net_sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_NET_C)

Expand Down
1 change: 1 addition & 0 deletions library/nist_kw.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/check_config.h"

#if defined(MBEDTLS_NIST_KW_C)

Expand Down
Loading