diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-10-05 17:07:59 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-10-05 17:07:59 +0000 |
commit | 8d0e66afdf4c7efedc33dedcc90e6414dde93ccb (patch) | |
tree | 7aac1fc6fdbb8b8e1e789b0df78a384c0f52a731 /ext/digest | |
parent | d93a35b55455d2d615f3c7df2057a62031f78d2f (diff) | |
download | ruby-8d0e66afdf4c7efedc33dedcc90e6414dde93ccb.tar.gz |
* ext/digest/digest.c (hexdigest_str_new): Add a string size check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/digest')
-rw-r--r-- | ext/digest/digest.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ext/digest/digest.c b/ext/digest/digest.c index f56a1921f8..63df4b126d 100644 --- a/ext/digest/digest.c +++ b/ext/digest/digest.c @@ -45,7 +45,14 @@ hexdigest_str_new(const unsigned char *digest, size_t digest_len) int i; VALUE str; char *p; - static const char hex[] = "0123456789abcdef"; + static const char hex[] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'a', 'b', 'c', 'd', 'e', 'f' + }; + + if (LONG_MAX / 2 < digest_len) { + rb_raise(rb_eRuntimeError, "digest string too long"); + } str = rb_str_new(0, digest_len * 2); |