From 58c57c57354fce407b11c0d63f8926edf5f469c0 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Fri, 24 Mar 2017 11:30:51 +0100 Subject: Missing overflow check in string.rep --- tests/single.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/single.lua b/tests/single.lua index 4bd159c..d9b6ce9 100644 --- a/tests/single.lua +++ b/tests/single.lua @@ -99,3 +99,9 @@ assert(string.lower("\0ABCc%$") == "\0abcc%$") assert(string.rep('teste', 0) == '') assert(string.rep('tés\00tê', 2) == 'tés\0têtés\000tê') assert(string.rep('', 10) == '') + +if string.packsize("i") == 4 then + -- result length would be 2^31 (int overflow) + checkerror("too large", string.rep, 'aa', (1 << 30)) + checkerror("too large", string.rep, 'a', (1 << 30), ',') +end -- cgit v1.2.3-54-g00ecf