mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/digest/digest.c (hexdigest_str_new, bubblebabble_str_new):
Perform StringValue() checks properly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f7579abcec
commit
775e54fe7b
2 changed files with 17 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Oct 10 16:39:08 2006 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
|
* ext/digest/digest.c (hexdigest_str_new, bubblebabble_str_new):
|
||||||
|
Perform StringValue() checks properly.
|
||||||
|
|
||||||
Tue Oct 10 13:21:21 2006 Akinori MUSHA <knu@iDaemons.org>
|
Tue Oct 10 13:21:21 2006 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
* ext/digest/sha1/depend, ext/digest/sha2/depend: Remove obsolete
|
* ext/digest/sha1/depend, ext/digest/sha2/depend: Remove obsolete
|
||||||
|
|
|
@ -42,8 +42,8 @@ get_digest_base_metadata(VALUE klass)
|
||||||
static VALUE
|
static VALUE
|
||||||
hexdigest_str_new(VALUE str_digest)
|
hexdigest_str_new(VALUE str_digest)
|
||||||
{
|
{
|
||||||
char *digest = RSTRING_PTR(str_digest);
|
char *digest;
|
||||||
size_t digest_len = RSTRING_LEN(str_digest);
|
size_t digest_len;
|
||||||
int i;
|
int i;
|
||||||
VALUE str;
|
VALUE str;
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -52,6 +52,10 @@ hexdigest_str_new(VALUE str_digest)
|
||||||
'a', 'b', 'c', 'd', 'e', 'f'
|
'a', 'b', 'c', 'd', 'e', 'f'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StringValue(str_digest);
|
||||||
|
digest = RSTRING_PTR(str_digest);
|
||||||
|
digest_len = RSTRING_LEN(str_digest);
|
||||||
|
|
||||||
if (LONG_MAX / 2 < digest_len) {
|
if (LONG_MAX / 2 < digest_len) {
|
||||||
rb_raise(rb_eRuntimeError, "digest string too long");
|
rb_raise(rb_eRuntimeError, "digest string too long");
|
||||||
}
|
}
|
||||||
|
@ -71,8 +75,8 @@ hexdigest_str_new(VALUE str_digest)
|
||||||
static VALUE
|
static VALUE
|
||||||
bubblebabble_str_new(VALUE str_digest)
|
bubblebabble_str_new(VALUE str_digest)
|
||||||
{
|
{
|
||||||
char *digest = RSTRING_PTR(str_digest);
|
char *digest;
|
||||||
size_t digest_len = RSTRING_LEN(str_digest);
|
size_t digest_len;
|
||||||
VALUE str;
|
VALUE str;
|
||||||
char *p;
|
char *p;
|
||||||
int i, j, seed = 1;
|
int i, j, seed = 1;
|
||||||
|
@ -84,6 +88,10 @@ bubblebabble_str_new(VALUE str_digest)
|
||||||
'p', 'r', 's', 't', 'v', 'z', 'x'
|
'p', 'r', 's', 't', 'v', 'z', 'x'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StringValue(str_digest);
|
||||||
|
digest = RSTRING_PTR(str_digest);
|
||||||
|
digest_len = RSTRING_LEN(str_digest);
|
||||||
|
|
||||||
if ((LONG_MAX - 2) / 3 < (digest_len | 1)) {
|
if ((LONG_MAX - 2) / 3 < (digest_len | 1)) {
|
||||||
rb_raise(rb_eRuntimeError, "digest string too long");
|
rb_raise(rb_eRuntimeError, "digest string too long");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue