From a4c9ddf05675429eeeb7a4f68859892db0837356 Mon Sep 17 00:00:00 2001 From: yumkam Date: Wed, 16 Oct 2024 11:46:51 +0300 Subject: [PATCH] Fix UB in right shift (#10422) --- ydb/library/yql/udfs/common/ip_base/lib/ip_base_udf.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ydb/library/yql/udfs/common/ip_base/lib/ip_base_udf.h b/ydb/library/yql/udfs/common/ip_base/lib/ip_base_udf.h index 0e89918311a2..1d8ba5e95a39 100644 --- a/ydb/library/yql/udfs/common/ip_base/lib/ip_base_udf.h +++ b/ydb/library/yql/udfs/common/ip_base/lib/ip_base_udf.h @@ -95,8 +95,7 @@ namespace { } static TRawIp6 MaskFromPrefix(ui8 prefix) { - ui128 x = ui128(-1) << int(128 - prefix); - if (prefix == 0) x = 0; + ui128 x = prefix == 0 ? ui128(0) : ui128(-1) << int(128 - prefix); return FromIpAddress({x, TIpv6Address::Ipv6}); }