aboutsummaryrefslogtreecommitdiff
path: root/testes/strings.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-07-23 18:12:53 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-07-23 18:12:53 -0300
commite3716ee161bb5416b5eb846eff6039d61954cfbd (patch)
tree4288e7f7ad1d74d375bb2923ad21ca7ecd44ba8f /testes/strings.lua
parent303f4155593721dfd57dadc6e56122e465ce9efb (diff)
downloadlua-master.tar.gz
lua-master.tar.bz2
lua-master.zip
Fix in string.repHEADmaster
The cast of n (number of repetitions) to size_t may truncate its value, causing a buffer overflow later. Better to check the buffer size using lua_Integer, as all string lengths must fit in a lua_Integer and n already is a lua_Integer. If everything fits in MAX_SIZE, then we can safely convert n to size_t and compute the buffer size as a size_t. As a corner case, n can be larger than size_t if the strings being repeated have length zero, but in this case it will be multiplied by zero, so an overflow in the cast is irrelevant.
Diffstat (limited to '')
0 files changed, 0 insertions, 0 deletions