@cryptotaxi247 / netdata-1 / commits / 3baba7a82

Fix UB in tzif_read_be64() (#22097)

Fix runtime error: left shift of 255 by 56 places cannot be represented in type 'long int'

Stelios Fragkakis committed Mar 31, 2026 at 21:21 UTC 3baba7a8295c89e6ebdeb9a02b719b1ce2d3367e
1 file changed +10 -8
src/daemon/analytics.c
+10 -8
@@ -965,14 +965,16 @@ static inline uint32_t tzif_read_be32(const unsigned char *src) {
965 }
966
967 static inline int64_t tzif_read_be64(const unsigned char *src) {
968 - return ((int64_t)(uint64_t)src[0] << 56) |
969 - ((int64_t)(uint64_t)src[1] << 48) |
970 - ((int64_t)(uint64_t)src[2] << 40) |
971 - ((int64_t)(uint64_t)src[3] << 32) |
972 - ((int64_t)(uint64_t)src[4] << 24) |
973 - ((int64_t)(uint64_t)src[5] << 16) |
974 - ((int64_t)(uint64_t)src[6] << 8) |
975 - (int64_t)(uint64_t)src[7];
968 + return (int64_t)(
969 + ((uint64_t)src[0] << 56) |
970 + ((uint64_t)src[1] << 48) |
971 + ((uint64_t)src[2] << 40) |
972 + ((uint64_t)src[3] << 32) |
973 + ((uint64_t)src[4] << 24) |
974 + ((uint64_t)src[5] << 16) |
975 + ((uint64_t)src[6] << 8) |
976 + (uint64_t)src[7]
977 + );
978 }
979
980 bool timezone_name_is_safe_tzdb_path(const char *timezone) {