From: Sergey Bronnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Sergey Kaplun <skaplun@tarantool.org>, Maxim Kokryashkin <m.kokryashkin@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH luajit] Limit exponent range in number parsing. Date: Thu, 25 Jan 2024 10:47:56 +0300 [thread overview] Message-ID: <fc4661f2-c2a1-40f1-b17e-596c4532a5eb@tarantool.org> (raw) In-Reply-To: <ZbAsOB8rIKe0APjb@root> Hi, Sergey! thanks for the patch! On 1/24/24 00:14, Sergey Kaplun wrote: <snipped> > +++ b/test/tarantool-tests/lj-788-limit-exponents-range.test.lua > @@ -0,0 +1,29 @@ > +local tap = require('tap') > + > +-- Test file to demonstrate incorrect behaviour of exponent number > +-- form parsing. > +-- See also: https://github.com/LuaJIT/LuaJIT/issues/788. > +local test = tap.test('lj-788-limit-exponents-range') > +test:plan(2) > + > +-- Before the patch, the powers greater than (1 << 16) * 10 > +-- (655360) were parsed incorrectly. After the patch, powers > +-- greater than 1 << 20 (1048576 `STRSCAN_MAXEXP`) are considered > +-- invalid. See <src/lj_strscan.c> for details. > +-- Choose the first value between these values and the second > +-- value bigger than `STRSCAN_MAXEXP` to check parsing correctness typical values on testing boundaries [1] are: value before the boundary, boundary value and value after the boundary. So I propose to test these three values. 1: https://en.wikipedia.org/wiki/Boundary-value_analysis > +-- for the first one, and `STRSCAN_ERROR` for the second case. > +local PARSABLE_EXP_POWER = 1000000 > +local TOO_LARGE_EXP_POWER = 1050000 > + > +local function form_exp_string(n) > + return '0.' .. string.rep('0', n - 1) .. '1e' .. tostring(n) > +end > + > +test:is(tonumber(form_exp_string(PARSABLE_EXP_POWER)), 1, > + 'correct parsing of large exponent') > + > +test:is(tonumber(form_exp_string(TOO_LARGE_EXP_POWER)), nil, > + 'too big exponent power is not parsed') > + > +test:done(true)
next prev parent reply other threads:[~2024-01-25 7:47 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-11-21 8:52 Sergey Kaplun via Tarantool-patches 2023-11-21 23:14 ` Maxim Kokryashkin via Tarantool-patches 2024-01-23 21:14 ` Sergey Kaplun via Tarantool-patches 2024-01-25 7:47 ` Sergey Bronnikov via Tarantool-patches [this message] 2024-01-25 10:06 ` Sergey Kaplun via Tarantool-patches 2024-01-25 16:31 ` Sergey Bronnikov via Tarantool-patches 2024-02-15 13:50 ` Igor Munkin via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=fc4661f2-c2a1-40f1-b17e-596c4532a5eb@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=m.kokryashkin@tarantool.org \ --cc=sergeyb@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH luajit] Limit exponent range in number parsing.' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox