summaryrefslogtreecommitdiff
path: root/strftime.c
diff options
context:
space:
mode:
authorngoto <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-30 13:41:45 +0000
committerngoto <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-30 13:41:45 +0000
commitcf310f97416686e93841e202462c8bb60fb332e6 (patch)
treeb26e75911ec47db7c320c64d1033f2e201515be8 /strftime.c
parent3761e00f87802b7eea43f037991dfe826e3575ab (diff)
* strftime.c (NEEDS): avoid SEGV due to integer overflow in sparc-solaris2.10
and i686-linux. fix [Bug #4456] [ruby-dev:43284] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'strftime.c')
-rw-r--r--strftime.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/strftime.c b/strftime.c
index 69ed924325..1164db01d1 100644
--- a/strftime.c
+++ b/strftime.c
@@ -210,7 +210,7 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, const str
if (precision > 0 || flags & (BIT_OF(LOCALE_E)|BIT_OF(LOCALE_O))) \
goto unknown; \
} while (0)
-#define NEEDS(n) do if (s + (n) >= endp - 1) goto err; while (0)
+#define NEEDS(n) do if (s >= endp || (n) >= endp - s - 1) goto err; while (0)
#define FILL_PADDING(i) do { \
if (!(flags & BIT_OF(LEFT)) && precision > (i)) { \
NEEDS(precision); \