diff options
author | John Hawthorn <[email protected]> | 2024-10-23 22:32:55 -0700 |
---|---|---|
committer | John Hawthorn <[email protected]> | 2024-11-08 17:39:19 -0800 |
commit | c8c94bfb1edd6e1e045d503dfba9a96077306a27 (patch) | |
tree | e1f002f103520a9fb55ff149f0a64e97ba30f5ce /sprintf.c | |
parent | 1f6dd9071c7994dd639d2e1cf2fe04e944173f17 (diff) |
Fix benign off-by-one
Previously we always reserved one more byte than necessary in the
sprintf output string.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12029
Diffstat (limited to 'sprintf.c')
-rw-r--r-- | sprintf.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -67,7 +67,8 @@ sign_bits(int base, const char *p) #define CHECK(l) do {\ int cr = ENC_CODERANGE(result);\ - while ((l) >= bsiz - blen) {\ + RUBY_ASSERT(bsiz >= blen); \ + while ((l) > bsiz - blen) {\ bsiz*=2;\ if (bsiz<0) rb_raise(rb_eArgError, "too big specifier");\ }\ |