From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 28DB76EC44; Fri, 6 Nov 2026 13:51:18 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 28DB76EC44 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1793962278; bh=MmwINPgyJh2lbBXltctlcvyE8+dizQifT0DCIp7QUC8=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Rd9zUgxmCJAg2ZzGS839mZWC2+TBAf+CNXYKi99wP9bamCr6bFr9BGu+QdJ1oBd26 IxxrVi+NJ0+oaxLZVPkl5d96+1x2+0THhY77FFU4cYF1m31YHHSEQbP/srPxkdqZYR a9NIRqS3b2rwNkjgCMygyjMkQPp3oOA5c8uPY7X0= Received: from send194.i.mail.ru (send194.i.mail.ru [95.163.59.33]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 153526EC44 for ; Fri, 6 Nov 2026 13:51:16 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 153526EC44 Received: by exim-smtp-5cc8b577fd-rs9pw with esmtpa (envelope-from ) id 1xPHXO-00000000HsR-2ZjW; Fri, 06 Nov 2026 13:51:15 +0300 Content-Type: multipart/alternative; boundary="------------93Ad1s9jVF4pRhBOKRWfKkMV" Message-ID: <514afe56-1a19-4f78-8a19-14db0c17db62@tarantool.org> Date: Fri, 6 Nov 2026 13:51:14 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Evgeniy Temirgaleev , Sergey Bronnikov Cc: tarantool-patches@dev.tarantool.org References: <1781178253.874466124@f309.i.mail.ru> Content-Language: en-US In-Reply-To: <1781178253.874466124@f309.i.mail.ru> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD96F2D5E088614A2378D785312DD6E7CD05F04CC532D68410A182A05F5380850404CE96D3DF5A00BC23DE06ABAFEAF67050245E6EE892BA848EBE7F5DC363E3FCF23B53866B3CF53F4 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE728F774C865CF4B07EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB5533756692EBD3885B996106ED8579609D729EA9883A05314898D86299FD12E5FBBC78F9389733CBF5DBD5E9D5E8D9A59859A8B6EC0BC6DB5D5D7B8BCC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8090A508E0FED6299176DF2183F8FC7C093FFA1BBD54C7608CD04E86FAF290E2DB606B96278B59C421DD303D21008E29813377AFFFEAFD269176DF2183F8FC7C0D75EB778CE7D8A0C68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CA1D607EB49F9BFEF43847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A58B452D02A8D188F85002B1117B3ED6968A495F2A89EADDC61A1B8FE1FED62FE8823CB91A9FED034534781492E4B8EEADC24E78AA85F86F6CBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D6590B54C87ABA55BA80FAEE3046DF90C666CA7F6E183759B5A7831E8A827BF51E68C0526E32FF663613B8341EE9D5BE9A0A1D202FBE05B0D43132912AA3C92F0EB377389445F2B99F776536EB022892E5344C41F94D744909CE2512F26BEC029E55448553D2254B8D95CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXOcIETfglQORZ0zpDET4Zrk3igikrdHlWJyYUCnpofT5m5/lFOSIJYM= X-Mailru-Sender: 520A125C2F17F0B17094CDC02B85F11BE92A6D28EE79C9813DE06ABAFEAF67050245E6EE892BA848B7CBEF92542CD7C8795FA72BAB74744FC77752E0C033A69EA16A481184E8BB1C9B38E6EA4F046BE03A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Prevent sanitizer warning in os.time(). X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------93Ad1s9jVF4pRhBOKRWfKkMV Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, Evgeniy, On 6/11/26 14:44, Evgeniy Temirgaleev via Tarantool-patches wrote: > > Hi, Sergey! Thanks for the patch! > Please, see my comment. > -- > Best regards, > Evgeniy Temirgaleev > > From: Sergey Bronnikov > To: tarantool-patches@dev.tarantool.org, Sergey Kaplun > ,e.temirgaleev@tarantool.org > Date: Friday, June 5, 2026 6:19 PM +03:00 > From: Mike Pall > > Reported by Sergey Bronnikov. > > (cherry picked from commit 86d414f5cae062b06998ec66b0696a47d4f6a0f0) > > The function `lj_cf_os_time()` calculates `tm_mon` and `tm_year` > values using `get_field()` and when the helper function returns > a negative value the resulted values may be negative as well. This > is an undefined behaviour (signed integer overflow). The patch fixes > that by adding a cast for the resulted value to returned by > `get_field()`. > > Sergey Bronnikov: > * added the description and the test for the problem > > Part of tarantool/tarantool#12480 > --- > > Branch: > https://github.com/tarantool/luajit/tree/ligurio/lj-1454-ub-os-time > > Related issues: > > * https://github.com/tarantool/tarantool/issues/12480 > * https://github.com/LuaJIT/LuaJIT/issues/1454 > > src/lib_os.c | 4 ++-- > test/tarantool-tests/lj-1454-os-time.test.lua | 19 +++++++++++++++++++ > 2 files changed, 21 insertions(+), 2 deletions(-) > create mode 100644 test/tarantool-tests/lj-1454-os-time.test.lua > > diff --git a/src/lib_os.c b/src/lib_os.c > index ffbc3fdc..0feb0d47 100644 > --- a/src/lib_os.c > +++ b/src/lib_os.c > @@ -239,8 +239,8 @@ LJLIB_CF(os_time) > ts.tm_min = getfield(L, "min", 0); > ts.tm_hour = getfield(L, "hour", 12); > ts.tm_mday = getfield(L, "day", -1); > - ts.tm_mon = getfield(L, "month", -1) - 1; > - ts.tm_year = getfield(L, "year", -1) - 1900; > + ts.tm_mon = (int)((unsigned int)getfield(L, "month", -1) - 1u); > + ts.tm_year = (int)((unsigned int)getfield(L, "year", -1) - 1900u); > > We just suppress signed integer-overflow warning implicitly by casting > (and get an unsigned integer-overflow warning instead — > try `luajit -e "os.time({ day = 0, month = 0, year = 0 })"` with clang > and -fsanitize=integer). Thanks for highlighting this! I've reported this to upstream [1]. 1. https://github.com/LuaJIT/LuaJIT/issues/1454#issuecomment-6683039935 --------------93Ad1s9jVF4pRhBOKRWfKkMV Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi, Evgeniy,

On 6/11/26 14:44, Evgeniy Temirgaleev via Tarantool-patches wrote:

Hi, Sergey! Thanks for the patch!
 
Please, see my comment.
 
--
Best regards,
Evgeniy Temirgaleev
 
From: Sergey Bronnikov <estetus@gmail.com>
To: tarantool-patches@dev.tarantool.org, Sergey Kaplun <skaplun@tarantool.org>,e.temirgaleev@tarantool.org
Date: Friday, June 5, 2026 6:19 PM +03:00

 
From: Mike Pall <mike>

Reported by Sergey Bronnikov.

(cherry picked from commit 86d414f5cae062b06998ec66b0696a47d4f6a0f0)

The function `lj_cf_os_time()` calculates `tm_mon` and `tm_year`
values using `get_field()` and when the helper function returns
a negative value the resulted values may be negative as well. This
is an undefined behaviour (signed integer overflow). The patch fixes
that by adding a cast for the resulted value to returned by
`get_field()`.

Sergey Bronnikov:
* added the description and the test for the problem

Part of tarantool/tarantool#12480
---

Branch: https://github.com/tarantool/luajit/tree/ligurio/lj-1454-ub-os-time

Related issues:

* https://github.com/tarantool/tarantool/issues/12480
* https://github.com/LuaJIT/LuaJIT/issues/1454

src/lib_os.c | 4 ++--
test/tarantool-tests/lj-1454-os-time.test.lua | 19 +++++++++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
create mode 100644 test/tarantool-tests/lj-1454-os-time.test.lua

diff --git a/src/lib_os.c b/src/lib_os.c
index ffbc3fdc..0feb0d47 100644
--- a/src/lib_os.c
+++ b/src/lib_os.c
@@ -239,8 +239,8 @@ LJLIB_CF(os_time)
ts.tm_min = getfield(L, "min", 0);
ts.tm_hour = getfield(L, "hour", 12);
ts.tm_mday = getfield(L, "day", -1);
- ts.tm_mon = getfield(L, "month", -1) - 1;
- ts.tm_year = getfield(L, "year", -1) - 1900;
+ ts.tm_mon = (int)((unsigned int)getfield(L, "month", -1) - 1u);
+ ts.tm_year = (int)((unsigned int)getfield(L, "year", -1) - 1900u);
We just suppress signed integer-overflow warning implicitly by casting (and get an unsigned integer-overflow warning instead —
try `luajit -e "os.time({ day = 0, month = 0, year = 0 })"` with clang and -fsanitize=integer).
 

Thanks for highlighting this!

I've reported this to upstream [1].

1. https://github.com/LuaJIT/LuaJIT/issues/1454#issuecomment-6683039935

<snipped> --------------93Ad1s9jVF4pRhBOKRWfKkMV--