[Tarantool-patches] [PATCH luajit] FFI: Fix pragma push stack limit check and throw on overflow.

Maxim Kokryashkin m.kokryashkin at tarantool.org
Wed Nov 8 21:59:36 MSK 2023


Hi, Sergey!
Thanks for the patch!
LGTM after fixing the comment left by Igor, and
one additional comment from me (see it below).

On Wed, Nov 08, 2023 at 11:40:44AM +0300, Sergey Kaplun wrote:
> From: Mike Pall <mike>
> 
> Reported by Sergey Kaplun.
> 
> (cherry-picked from commit 433d7e8d8d182f44e88b5cfdc4b2d3026469dfb7)
> 
> `cp->packstack` is the array of size `CPARSE_MAX_PACKSTACK` (7). Before
> the patch, `cp->curpack` is checked to be less than
> `CPARSE_MAX_PACKSTACK`, but then `cp->packstack` is accessed at
> `cp->curpack + 1`, which is out of bounds, so `cp->curpack` value is
> overwritten.
> 
> This patch fixes a condition and also adds the error throw when counter
> is overflow (instead of rewriting a top `cp->packstack` value).
> 
> Sergey Kaplun:
> * added the description and the test for the problem
> 
> Resolves tarantool/tarantool#9339
> Part of tarantool/tarantool#9145
> ---
> 
> Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-1114-ffi-pragma-pack
> Tarantool PR: https://github.com/tarantool/tarantool/pull/9342
> Relate issues:
> * https://github.com/LuaJIT/LuaJIT/issues/1114
> * https://github.com/tarantool/tarantool/issues/9339
> * https://github.com/tarantool/tarantool/issues/9145
> 
>  src/lj_cparse.c                               |  4 +-
>  .../lj-1114-ffi-pragma-pack.test.lua          | 44 +++++++++++++++++++
>  2 files changed, 47 insertions(+), 1 deletion(-)
>  create mode 100644 test/tarantool-tests/lj-1114-ffi-pragma-pack.test.lua
> 
> diff --git a/src/lj_cparse.c b/src/lj_cparse.c
> index 6d9490ca..01deb3bf 100644
> --- a/src/lj_cparse.c
> +++ b/src/lj_cparse.c
<snipped>

> diff --git a/test/tarantool-tests/lj-1114-ffi-pragma-pack.test.lua b/test/tarantool-tests/lj-1114-ffi-pragma-pack.test.lua
> new file mode 100644
> index 00000000..e5642828
> --- /dev/null
> +++ b/test/tarantool-tests/lj-1114-ffi-pragma-pack.test.lua
> @@ -0,0 +1,44 @@
<snipped>

> +test:ok(not err, 'the error is thrown when couner overflows')
Typo: s/couner/counter/

> +test:like(msg, 'chunk has too many syntax levels',
> +          'the error message is correct')
> +
> +test:done(true)
> -- 
> 2.42.0
> 


More information about the Tarantool-patches mailing list