libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 49942a4a3feffeeb592323959cfd0b42718548f1
parent a4b7990e5bb827521b43689d690a97aa8d496ddd
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Wed, 13 Sep 2023 17:10:44 +0300

W32 VS: really muted run-time warnings about data truncation

Diffstat:
Msrc/include/mhd_options.h | 9+++++++++
Msrc/microhttpd/digestauth.c | 8++++++++
Msrc/microhttpd/md5.c | 5+++++
Msrc/microhttpd/mhd_bithelpers.h | 2++
Msrc/microhttpd/mhd_str.c | 7+++++++
Msrc/microhttpd/sha256.c | 5+++++
Msrc/microhttpd/sha512_256.c | 5+++++
Mw32/common/common-build-settings.props | 1-
8 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/src/include/mhd_options.h b/src/include/mhd_options.h @@ -172,6 +172,15 @@ #endif /* ! (MHD_ASAN_ACTIVE && HAVE_SANITIZER_ASAN_INTERFACE_H && (FUNC_ATTR_PTRCOMPARE_WORKS || FUNC_ATTR_NOSANITIZE_WORKS)) */ +#ifndef _MSC_FULL_VER +# define MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ /* empty */ +# define MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ /* empty */ +#else /* _MSC_FULL_VER */ +# define MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ \ + __pragma(runtime_checks("c", off)) +# define MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ \ + __pragma(runtime_checks("c", restore)) +#endif /* _MSC_FULL_VER */ /** * Automatic string with the name of the current function diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c @@ -764,6 +764,8 @@ get_nonce_timestamp (const char *const nonce, } +MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ + /** * Super-fast xor-based "hash" function * @@ -791,6 +793,8 @@ fast_simple_hash (const uint8_t *data, } +MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ + /** * Get index of the nonce in the nonce-nc map array. * @@ -1756,6 +1760,8 @@ calculate_add_nonce (struct MHD_Connection *const connection, } +MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ + /** * Calculate the server nonce so that it mitigates replay attacks and add * the new nonce to the nonce-nc map array. @@ -1859,6 +1865,8 @@ calculate_add_nonce_with_retry (struct MHD_Connection *const connection, } +MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ + /** * Calculate userdigest, return it as binary data. * diff --git a/src/microhttpd/md5.c b/src/microhttpd/md5.c @@ -54,6 +54,8 @@ MHD_MD5_init (struct Md5Ctx *ctx) } +MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ + /** * Base of MD5 transformation. * Gets full 64 bytes block of data and updates hash values; @@ -544,3 +546,6 @@ MHD_MD5_finish (struct Md5Ctx *ctx, /* Erase potentially sensitive data. */ memset (ctx, 0, sizeof(struct Md5Ctx)); } + + +MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ diff --git a/src/microhttpd/mhd_bithelpers.h b/src/microhttpd/mhd_bithelpers.h @@ -45,6 +45,7 @@ # define _MHD_has_builtin_dummy 1 #endif +MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ #ifdef MHD_HAVE___BUILTIN_BSWAP32 #define _MHD_BYTES_SWAP32(value32) \ @@ -388,6 +389,7 @@ _MHD_ROTR64 (uint64_t value64, int bits) #endif /* ! __builtin_rotateright64 */ +MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ #ifdef _MHD_has_builtin_dummy /* Remove macro function replacement to avoid misdetection in files which diff --git a/src/microhttpd/mhd_str.c b/src/microhttpd/mhd_str.c @@ -2259,6 +2259,10 @@ base64_char_to_value_ (uint8_t c) #endif /* MHD_BASE64_FUNC_VERSION == 1 */ + +MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ + + size_t MHD_base64_to_bin_n (const char *base64, size_t base64_len, @@ -2428,6 +2432,9 @@ MHD_base64_to_bin_n (const char *base64, } +MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ + + #undef MHD_base64_map_type_ #endif /* BAUTH_SUPPORT */ diff --git a/src/microhttpd/sha256.c b/src/microhttpd/sha256.c @@ -58,6 +58,8 @@ MHD_SHA256_init (struct Sha256Ctx *ctx) } +MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ + /** * Base of SHA-256 transformation. * Gets full 64 bytes block of data and updates hash values; @@ -558,3 +560,6 @@ MHD_SHA256_finish (struct Sha256Ctx *ctx, /* Erase potentially sensitive data. */ memset (ctx, 0, sizeof(struct Sha256Ctx)); } + + +MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ diff --git a/src/microhttpd/sha512_256.c b/src/microhttpd/sha512_256.c @@ -58,6 +58,8 @@ MHD_SHA512_256_init (struct Sha512_256Ctx *ctx) } +MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ + /** * Base of SHA-512/256 transformation. * Gets full 128 bytes block of data and updates hash values; @@ -627,3 +629,6 @@ MHD_SHA512_256_finish (struct Sha512_256Ctx *ctx, /* Erase potentially sensitive data. */ memset (ctx, 0, sizeof(struct Sha512_256Ctx)); } + + +MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ diff --git a/w32/common/common-build-settings.props b/w32/common/common-build-settings.props @@ -92,7 +92,6 @@ <ItemDefinitionGroup Condition="'$(UseDebugLibraries)'=='true'"> <ClCompile> <Optimization>Disabled</Optimization> - <SmallerTypeCheck>true</SmallerTypeCheck> <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ClCompile> <ResourceCompile>