diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-07-23 18:12:53 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-07-23 18:12:53 -0300 |
commit | e3716ee161bb5416b5eb846eff6039d61954cfbd (patch) | |
tree | 4288e7f7ad1d74d375bb2923ad21ca7ecd44ba8f /lutf8lib.c | |
parent | 303f4155593721dfd57dadc6e56122e465ce9efb (diff) | |
download | lua-e3716ee161bb5416b5eb846eff6039d61954cfbd.tar.gz lua-e3716ee161bb5416b5eb846eff6039d61954cfbd.tar.bz2 lua-e3716ee161bb5416b5eb846eff6039d61954cfbd.zip |
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 'lutf8lib.c')
0 files changed, 0 insertions, 0 deletions