summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-sprintf/src/sprintf.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2016-12-17 23:37:35 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2016-12-18 02:02:30 +0900
commit432570723d027313f0d8dd5d3724fbc53f160e5c (patch)
tree7def7567089a75eb3151d111858ef627438c2baa /mrbgems/mruby-sprintf/src/sprintf.c
parent2edf15bed8026754ba09a770903bd7c50c9a81b8 (diff)
downloadmruby-432570723d027313f0d8dd5d3724fbc53f160e5c.tar.gz
mruby-432570723d027313f0d8dd5d3724fbc53f160e5c.zip
Check if width is zero or negative before fill; fix #3347
Reported by https://hackerone.com/haquaman.
Diffstat (limited to 'mrbgems/mruby-sprintf/src/sprintf.c')
-rw-r--r--mrbgems/mruby-sprintf/src/sprintf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mrbgems/mruby-sprintf/src/sprintf.c b/mrbgems/mruby-sprintf/src/sprintf.c
index d4290ec59..b5f9284d9 100644
--- a/mrbgems/mruby-sprintf/src/sprintf.c
+++ b/mrbgems/mruby-sprintf/src/sprintf.c
@@ -720,10 +720,10 @@ retry:
CHECK(n);
memcpy(buf+blen, c, n);
blen += n;
- FILL(' ', width-1);
+ if (width>0) FILL(' ', width-1);
}
else {
- FILL(' ', width-1);
+ if (width>0) FILL(' ', width-1);
CHECK(n);
memcpy(buf+blen, c, n);
blen += n;