]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Disable undefined behaviour sanitization for select locations
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 13 Aug 2020 08:36:08 +0000 (11:36 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 22 Oct 2020 12:16:16 +0000 (12:16 +0000)
src/auth/crypt-blowfish.c
src/lib-http/http-client-peer.c
src/lib-otp/otp-parse.c
src/lib/bits.h
src/lib/buffer.c
src/lib/data-stack.c
src/lib/hash.c
src/lib/md4.c
src/lib/md5.c
src/lib/strnum.c
src/lib/test-bits.c

index 0530198ef58e876906180dbe36f77778a41e51d6..ee9431796947090d17195fcf5e3a5718f889a9e0 100644 (file)
@@ -640,7 +640,9 @@ static const unsigned char flags_by_subtype[26] =
        {2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0};
 
-static char *BF_crypt(const char *key, const char *setting,
+static char * ATTR_NO_SANITIZE_UNDEFINED ATTR_NO_SANITIZE_INTEGER
+       ATTR_NO_SANITIZE_IMPLICIT_CONVERSION
+BF_crypt(const char *key, const char *setting,
        char *output, size_t size,
        BF_word min)
 {
index f8c2ecb42ef28102d076ba7d1590ff35a35b0ba3..d11159f8695f7a2da054a75d2457ca0c13c600a8 100644 (file)
@@ -33,8 +33,8 @@ http_client_peer_connection_failed_pool(struct http_client_peer *peer,
  * Peer address
  */
 
-unsigned int http_client_peer_addr_hash
-(const struct http_client_peer_addr *peer)
+unsigned int ATTR_NO_SANITIZE_INTEGER
+http_client_peer_addr_hash(const struct http_client_peer_addr *peer)
 {
        unsigned int hash = (unsigned int)peer->type;
 
index 4c686284780dcfb0bac8dabf8456f07134972113..70b69405190569be4a038dd10561f0fc62d086d0 100644 (file)
@@ -74,7 +74,8 @@ int otp_read_hex(const char *data, const char **endptr, unsigned char *hash)
        count++; \
 } while (0)
 
-int otp_read_words(const char *data, const char **endptr, unsigned char *hash)
+int ATTR_NO_SANITIZE_INTEGER
+otp_read_words(const char *data, const char **endptr, unsigned char *hash)
 {
        bool space = FALSE;
        unsigned int len = 0, count = 0;
index 430ae8ec3f1462f5b775a137955bd11acd15159f..586b166e76abd0ab9445ea47688feaeafde8ff90 100644 (file)
@@ -67,7 +67,8 @@ unsigned int bits_required64(uint64_t num)
 }
 #endif
 
-static inline uint64_t
+static inline uint64_t ATTR_NO_SANITIZE_INTEGER
+       ATTR_NO_SANITIZE_IMPLICIT_CONVERSION
 bits_rotl64(uint64_t num, unsigned int count)
 {
        const unsigned int mask = CHAR_BIT*sizeof(num) - 1;
@@ -75,7 +76,8 @@ bits_rotl64(uint64_t num, unsigned int count)
        return (num << count) | (num >> (-count & mask));
 }
 
-static inline uint32_t
+static inline uint32_t ATTR_NO_SANITIZE_INTEGER
+       ATTR_NO_SANITIZE_IMPLICIT_CONVERSION
 bits_rotl32(uint32_t num, unsigned int count)
 {
         const unsigned int mask = CHAR_BIT*sizeof(num) - 1;
@@ -83,7 +85,8 @@ bits_rotl32(uint32_t num, unsigned int count)
         return (num << count) | (num >> (-count & mask));
 }
 
-static inline uint64_t
+static inline uint64_t ATTR_NO_SANITIZE_INTEGER
+       ATTR_NO_SANITIZE_IMPLICIT_CONVERSION
 bits_rotr64(uint64_t num, unsigned int count)
 {
        const unsigned int mask = CHAR_BIT*sizeof(num) - 1;
@@ -91,7 +94,8 @@ bits_rotr64(uint64_t num, unsigned int count)
        return (num >> count) | (num << (-count & mask));
 }
 
-static inline uint32_t
+static inline uint32_t ATTR_NO_SANITIZE_INTEGER
+       ATTR_NO_SANITIZE_IMPLICIT_CONVERSION
 bits_rotr32(uint32_t num, unsigned int count)
 {
        const unsigned int mask = CHAR_BIT*sizeof(num) - 1;
@@ -143,7 +147,8 @@ bits_fraclog_bucket_start(unsigned int bucket, unsigned int fracbits)
        unsigned int bandstart = fracoffs1 << (bandnum - 1);
        return bandstart;
 }
-static inline unsigned int ATTR_CONST
+static inline unsigned int ATTR_CONST ATTR_NO_SANITIZE_INTEGER
+       ATTR_NO_SANITIZE_IMPLICIT_CONVERSION
 bits_fraclog_bucket_end(unsigned int bucket, unsigned int fracbits)
 {
        unsigned int bandnum = bucket >> fracbits;
index 41b879022eca11834c8cfda2365c1d4ee06dc670..f9a5f2659a62e481189f8b50972211ad624feceb 100644 (file)
@@ -419,7 +419,9 @@ void buffer_verify_pool(buffer_t *_buf)
        }
 }
 
-void buffer_truncate_rshift_bits(buffer_t *buf, size_t bits)
+void ATTR_NO_SANITIZE_IMPLICIT_CONVERSION
+       ATTR_NO_SANITIZE_INTEGER
+buffer_truncate_rshift_bits(buffer_t *buf, size_t bits)
 {
        /* no-op if it's shorten than bits in any case.. */
        if (buf->used * 8 < bits) return;
index 82887991a424268f36448eae92e17ee4d522c639..a408756b7887e39b3772039b7d946b96c62c611f 100644 (file)
@@ -468,7 +468,8 @@ void *t_malloc0(size_t size)
        return mem;
 }
 
-bool t_try_realloc(void *mem, size_t size)
+bool ATTR_NO_SANITIZE_INTEGER
+t_try_realloc(void *mem, size_t size)
 {
        size_t debug_adjust = 0, last_alloc_size;
        unsigned char *after_last_alloc;
index 4b1e6a000cc08d761cd4262b11675d44f94853b8..76d51baaaabda335596e8199da603f95e48758c0 100644 (file)
@@ -537,7 +537,8 @@ unsigned int str_hash(const char *p)
 }
 
 /* a char* hash function from ASU -- from glib */
-unsigned int strcase_hash(const char *p)
+unsigned int ATTR_NO_SANITIZE_INTEGER
+strcase_hash(const char *p)
 {
         const unsigned char *s = (const unsigned char *)p;
        unsigned int g, h = 0;
@@ -554,7 +555,8 @@ unsigned int strcase_hash(const char *p)
        return h;
 }
 
-unsigned int mem_hash(const void *p, unsigned int size)
+unsigned int ATTR_NO_SANITIZE_INTEGER
+mem_hash(const void *p, unsigned int size)
 {
        const unsigned char *s = p;
        unsigned int i, g, h = 0;
@@ -570,7 +572,8 @@ unsigned int mem_hash(const void *p, unsigned int size)
        return h;
 }
 
-unsigned int strfastcase_hash(const char *p)
+unsigned int ATTR_NO_SANITIZE_INTEGER
+strfastcase_hash(const char *p)
 {
        const unsigned char *s = (const unsigned char *)p;
        unsigned int g, h = 0;
index e23b35d3fae8d014fb532b2459d09b917083eb28..87228505b788bd95354f15253fbf159f732bdb63 100644 (file)
@@ -66,6 +66,8 @@
  * the bit counters.  There're no alignment requirements.
  */
 static const void * ATTR_NOWARN_UNUSED_RESULT ATTR_UNSIGNED_WRAPS
+       ATTR_NO_SANITIZE_UNDEFINED ATTR_NO_SANITIZE_INTEGER
+       ATTR_NO_SANITIZE_IMPLICIT_CONVERSION
 body(struct md4_context *ctx, const void *data, size_t size)
 {
        const unsigned char *ptr;
@@ -208,7 +210,9 @@ void md4_update(struct md4_context *ctx, const void *data, size_t size)
        memcpy(ctx->buffer, data, size);
 }
 
-void md4_final(struct md4_context *ctx, unsigned char result[STATIC_ARRAY MD4_RESULTLEN])
+void ATTR_NO_SANITIZE_UNDEFINED ATTR_NO_SANITIZE_INTEGER
+       ATTR_NO_SANITIZE_IMPLICIT_CONVERSION
+md4_final(struct md4_context *ctx, unsigned char result[STATIC_ARRAY MD4_RESULTLEN])
 {
        /* @UNSAFE */
        unsigned long used, free;
index bd4134084349af1e82dcaaddc384621e7aabaf96..096e10fff58d56ef774e3795941ae76cdafb7d55 100644 (file)
@@ -67,6 +67,8 @@
  * the bit counters.  There're no alignment requirements.
  */
 static const void * ATTR_NOWARN_UNUSED_RESULT ATTR_UNSIGNED_WRAPS
+        ATTR_NO_SANITIZE_UNDEFINED ATTR_NO_SANITIZE_INTEGER
+        ATTR_NO_SANITIZE_IMPLICIT_CONVERSION
 body(struct md5_context *ctx, const void *data, size_t size)
 {
        const unsigned char *ptr;
@@ -222,7 +224,8 @@ md5_update(struct md5_context *ctx, const void *data, size_t size)
        memcpy(ctx->buffer, data, size);
 }
 
-void ATTR_UNSIGNED_WRAPS
+void ATTR_UNSIGNED_WRAPS ATTR_NO_SANITIZE_UNDEFINED
+       ATTR_NO_SANITIZE_INTEGER ATTR_NO_SANITIZE_IMPLICIT_CONVERSION
 md5_final(struct md5_context *ctx, unsigned char result[STATIC_ARRAY MD5_RESULTLEN])
 {
        /* @UNSAFE */
index 2d0cdea3179f4f05991f7a97f70fb2be5d9ebb3a..fe1bdbca63e3d59521cc4ff942a197f93c7c99f7 100644 (file)
@@ -314,8 +314,8 @@ STR_TO_S__TEMPLATE(str_to_llong, long long, LLONG_MIN, LLONG_MAX)
 STR_TO_S__TEMPLATE(str_to_int32, int32_t, INT32_MIN, INT32_MAX)
 STR_TO_S__TEMPLATE(str_to_int64, int64_t, INT64_MIN, INT64_MAX)
 
-int str_parse_intmax(const char *str, intmax_t *num_r,
-       const char **endp_r)
+int ATTR_NO_SANITIZE_IMPLICIT_CONVERSION ATTR_NO_SANITIZE_INTEGER
+str_parse_intmax(const char *str, intmax_t *num_r, const char **endp_r)
 {
        bool neg = FALSE;
        uintmax_t l;
index 8379c0673d44ac6b70055ce3f8faced1ec49a783..86ad0f1a3371a1dce6d966287a4d57fcefd7e499 100644 (file)
@@ -97,7 +97,8 @@ static void test_sum_overflows(void)
        test_end();
 }
 
-static void test_bits_fraclog(void)
+static void ATTR_NO_SANITIZE_INTEGER ATTR_NO_SANITIZE_IMPLICIT_CONVERSION
+test_bits_fraclog(void)
 {
        unsigned int fracbits;
        for (fracbits = 0; fracbits < 6; fracbits++) {
@@ -124,7 +125,8 @@ static void test_bits_fraclog(void)
 /* The compiler *should* generate different code when the fracbits parameter
    is a compile-time constant, so we also need to check that's the case.
 */
-static void test_bits_fraclog_const(void)
+static void ATTR_NO_SANITIZE_INTEGER ATTR_NO_SANITIZE_IMPLICIT_CONVERSION
+test_bits_fraclog_const(void)
 {
 #define FRACBITS 2
 #define STR2(s) #s