aboutsummaryrefslogtreecommitdiffstats
path: root/ext/date/date_strptime.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-01 06:19:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-01 06:19:05 +0000
commit480a21f435d2917190c087206bbffbd3d532824a (patch)
treee2fbc5c118e07e470c0adb5ae659859fa69cd849 /ext/date/date_strptime.c
parent8c90838f7cfb69bb7c203d6758739f9e890faba4 (diff)
downloadruby-480a21f435d2917190c087206bbffbd3d532824a.tar.gz
RSTRING_PTR may not be terminated in the future
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/date/date_strptime.c')
-rw-r--r--ext/date/date_strptime.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/ext/date/date_strptime.c b/ext/date/date_strptime.c
index 877baea435..4383eb6fa1 100644
--- a/ext/date/date_strptime.c
+++ b/ext/date/date_strptime.c
@@ -79,14 +79,17 @@ read_digits(const char *s, VALUE *n, size_t width)
{
size_t l;
- l = strspn(s, "0123456789");
+ if (!width)
+ return 0;
+
+ l = 0;
+ while (ISDIGIT(s[l])) {
+ if (++l == width) break;
+ }
if (l == 0)
return 0;
- if (width < l)
- l = width;
-
if ((4 * l * sizeof(char)) <= (sizeof(long)*CHAR_BIT)) {
const char *os = s;
long v;