<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi, Evgeniy,</p>
<div class="moz-cite-prefix">On 6/11/26 14:44, Evgeniy Temirgaleev
via Tarantool-patches wrote:<br>
</div>
<blockquote type="cite"
cite="mid:1781178253.874466124@f309.i.mail.ru">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div class="cl-sq0u197qde">
<div><br>
Hi, Sergey! Thanks for the patch!<br>
</div>
<div>Please, see my comment.</div>
<div> </div>
<div>
<div>--<br>
Best regards,</div>
<div>Evgeniy Temirgaleev</div>
</div>
<div> </div>
<div class="mail-quote-collapse">
<blockquote
style="border-left:1px solid #0857A6;margin:10px;padding:0 0 0 10px"><span>From:
Sergey Bronnikov <<a href="mailto:estetus@gmail.com"
moz-do-not-send="true" class="moz-txt-link-freetext">estetus@gmail.com</a>><br>
To: <a class="moz-txt-link-abbreviated" href="mailto:tarantool-patches@dev.tarantool.org">tarantool-patches@dev.tarantool.org</a>, Sergey Kaplun
<<a href="mailto:skaplun@tarantool.org"
moz-do-not-send="true" class="moz-txt-link-freetext">skaplun@tarantool.org</a>>,<a
href="mailto:e.temirgaleev@tarantool.org"
moz-do-not-send="true" class="moz-txt-link-freetext">e.temirgaleev@tarantool.org</a><br>
Date: Friday, June 5, 2026 6:19 PM +03:00</span><br>
<div>
<div id="">
<div class="cl-851jltyjq5">
<div
class="js-helper_mr_css_attr js-readmsg-msg_mr_css_attr">
<div id="style_17806727590583898164_mr_css_attr">
<div
id="style_17806727590583898164_BODY_mr_css_attr">From:
Mike Pall <mike><br>
<br>
Reported by Sergey Bronnikov.<br>
<br>
(cherry picked from commit
86d414f5cae062b06998ec66b0696a47d4f6a0f0)<br>
<br>
The function `lj_cf_os_time()` calculates
`tm_mon` and `tm_year`<br>
values using `get_field()` and when the helper
function returns<br>
a negative value the resulted values may be
negative as well. This<br>
is an undefined behaviour (signed integer
overflow). The patch fixes<br>
that by adding a cast for the resulted value to
returned by<br>
`get_field()`.<br>
<br>
Sergey Bronnikov:<br>
* added the description and the test for the
problem<br>
<br>
Part of tarantool/tarantool#12480<br>
---<br>
<br>
Branch: <a
href="https://github.com/tarantool/luajit/tree/ligurio/lj-1454-ub-os-time"
moz-do-not-send="true"
class="moz-txt-link-freetext">https://github.com/tarantool/luajit/tree/ligurio/lj-1454-ub-os-time</a><br>
<br>
Related issues:<br>
<br>
* <a
href="https://github.com/tarantool/tarantool/issues/12480"
moz-do-not-send="true"
class="moz-txt-link-freetext">https://github.com/tarantool/tarantool/issues/12480</a><br>
* <a
href="https://github.com/LuaJIT/LuaJIT/issues/1454"
moz-do-not-send="true"
class="moz-txt-link-freetext">https://github.com/LuaJIT/LuaJIT/issues/1454</a><br>
<br>
src/lib_os.c | 4 ++--<br>
test/tarantool-tests/lj-1454-os-time.test.lua |
19 +++++++++++++++++++<br>
2 files changed, 21 insertions(+), 2
deletions(-)<br>
create mode 100644
test/tarantool-tests/lj-1454-os-time.test.lua<br>
<br>
diff --git a/src/lib_os.c b/src/lib_os.c<br>
index ffbc3fdc..0feb0d47 100644<br>
--- a/src/lib_os.c<br>
+++ b/src/lib_os.c<br>
@@ -239,8 +239,8 @@ LJLIB_CF(os_time)<br>
ts.tm_min = getfield(L, "min", 0);<br>
ts.tm_hour = getfield(L, "hour", 12);<br>
ts.tm_mday = getfield(L, "day", -1);<br>
- ts.tm_mon = getfield(L, "month", -1) - 1;<br>
- ts.tm_year = getfield(L, "year", -1) - 1900;<br>
+ ts.tm_mon = (int)((unsigned int)getfield(L,
"month", -1) - 1u);<br>
+ ts.tm_year = (int)((unsigned int)getfield(L,
"year", -1) - 1900u);</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
<div>We just suppress signed integer-overflow warning implicitly
by casting (and get an unsigned integer-overflow warning instead
—</div>
</blockquote>
<blockquote type="cite"
cite="mid:1781178253.874466124@f309.i.mail.ru">
<div>try `luajit -e "os.time({ day = 0, month = 0, year = 0 })"`
with clang and -fsanitize=integer).</div>
<div>
<div>
<div> </div>
</div>
</div>
</blockquote>
<p>Thanks for highlighting this!</p>
<p>I've reported this to upstream [1].</p>
<p>1.
<a class="moz-txt-link-freetext" href="https://github.com/LuaJIT/LuaJIT/issues/1454#issuecomment-6683039935">https://github.com/LuaJIT/LuaJIT/issues/1454#issuecomment-6683039935</a></p>
<snipped>
</body>
</html>