]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
io: drop the dead/unnecessary read_varint UBSan guard
authorAndrew Tridgell <andrew@tridgell.net>
Sun, 7 Jun 2026 22:09:10 +0000 (08:09 +1000)
committerAndrew Tridgell <andrew@tridgell.net>
Mon, 8 Jun 2026 10:54:57 +0000 (20:54 +1000)
The cherry-picked #428 wrapped no_sanitize attributes on read_varint() and
read_varlong() in `#ifndef CAREFUL_ALIGNMENT`, but byteorder.h always
#defines CAREFUL_ALIGNMENT (to 0 or 1), so that guard is never true and the
attributes were dead code.

They are also unnecessary: both functions read the assembled value through
an aligned union member (union { char b[5]; int32 x; }), not an unaligned
cast, so UBSan's alignment check never fires there (verified: the ASan+UBSan
suite is clean without them).  Remove the whole block rather than fix the
guard.  (The byteorder.h annotations from #428, which are real and correctly
placed inside the !CAREFUL_ALIGNMENT branch, are kept.)

io.c

diff --git a/io.c b/io.c
index 8d240e441d54ae4d68325404f251a9dc9abb4c5d..0b96c27095650369cc01d9dd064b94d58d09b8ea 100644 (file)
--- a/io.c
+++ b/io.c
@@ -1813,13 +1813,6 @@ uint32 read_uint(int f)
        return IVAL(b, 0);
 }
 
-#ifndef CAREFUL_ALIGNMENT
-#ifdef __clang__
-__attribute__((no_sanitize("undefined")))
-#elif GCC_VERSION >= 409
-__attribute__((no_sanitize_undefined))
-#endif
-#endif
 int32 read_varint(int f)
 {
        union {
@@ -1852,13 +1845,6 @@ int32 read_varint(int f)
        return u.x;
 }
 
-#ifndef CAREFUL_ALIGNMENT
-#ifdef __clang__
-__attribute__((no_sanitize("undefined")))
-#elif GCC_VERSION >= 409
-__attribute__((no_sanitize_undefined))
-#endif
-#endif
 int64 read_varlong(int f, uchar min_bytes)
 {
        union {