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 6C61E9ABE89; Thu, 25 Jan 2024 10:47:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6C61E9ABE89 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1706168878; bh=HtQgz8S96s79eh3cJ+gZtRiO8rted3FMyD3yDn9WJR8=; 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=J5vGIb81GRy+FNmpq6SP5UWmQK0Xn5R3ucaLY6sYrT+byOX47QiD1a2TVsDT/rVMC K/bJxc3ickQSky+iZsqyV6z5ZQ9007llhJxIRfKPymK+HMrk0xjX7mbiHb5QXDQUUt 0HbsU7SEowfjEJSJuEjN53S17m+ABwCLF8rSCyYs= Received: from smtp16.i.mail.ru (smtp16.i.mail.ru [95.163.41.69]) (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 886DF32B7C1 for ; Thu, 25 Jan 2024 10:47:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 886DF32B7C1 Received: by smtp16.i.mail.ru with esmtpa (envelope-from ) id 1rSuSq-005GBJ-2i; Thu, 25 Jan 2024 10:47:57 +0300 Message-ID: Date: Thu, 25 Jan 2024 10:47:56 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Sergey Kaplun , Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org References: <20231121085253.13526-1-skaplun@tarantool.org> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD96A58C36AA2E996498065D321F2FD018AEFC0421552190AD0182A05F5380850408F05157EE0F9ECACDCEB15DC597A67F43D545242EAE4057F8C4EB053A1273685 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE742D9BD90C58D50E0EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006377A7A7D315BEE81B48638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D83BD1A2A1ED343E8A7C10F761860056B0117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCB37B5D51F58B3735A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520140C956E756FBB7A618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE9647ADFADE5905B197A342136F30543AD8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE34E7D9683544204AF6136E347CC761E07C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947C1D471462564A2E192E808ACE2090B5E1725E5C173C3A84C3ED8438A78DFE0A9E089D37D7C0E48F6C8AA50765F7900637A63D8D502DFAF8B5731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A53D18E50F36138CB28D473ABFA5034CE47DE98A16635393DAF87CCE6106E1FC07E67D4AC08A07B9B07BD21ED50D08CA4DCB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF02CAB1E1259B7EBD6D6990D750480645B43FE3028249EDE38DF94D86DA3B518C141C0AB2DA7D0DDA4BEAD515961AA0A765F1BA2F603E4535B83A83C77B928C52E48CAC7CA610320002C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojjPo90oGNxwJ3A4eesl4Puw== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A769EC297430B6BBB3AADCEB15DC597A67F4F43CCAED39DA92F1EBA65886582A37BD66FEC6BF5C9C28D98A98C1125256619760D574B6FC815AB872D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Limit exponent range in number parsing. 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" Hi, Sergey! thanks for the patch! On 1/24/24 00:14, Sergey Kaplun wrote: > +++ 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 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)