summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authorJohn Hawthorn <[email protected]>2024-10-23 22:32:55 -0700
committerJohn Hawthorn <[email protected]>2024-11-08 17:39:19 -0800
commitc8c94bfb1edd6e1e045d503dfba9a96077306a27 (patch)
treee1f002f103520a9fb55ff149f0a64e97ba30f5ce /sprintf.c
parent1f6dd9071c7994dd639d2e1cf2fe04e944173f17 (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.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sprintf.c b/sprintf.c
index 9290ed726c..cb266a9841 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -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");\
}\