mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Merged too-short salt conditions instead of UNREACHABLE_RETURN
This commit is contained in:
parent
f3f78f9654
commit
81f17857a7
1 changed files with 4 additions and 9 deletions
13
string.c
13
string.c
|
@ -9749,13 +9749,12 @@ rb_str_crypt(VALUE str, VALUE salt)
|
||||||
StringValue(salt);
|
StringValue(salt);
|
||||||
mustnot_wchar(str);
|
mustnot_wchar(str);
|
||||||
mustnot_wchar(salt);
|
mustnot_wchar(salt);
|
||||||
if (RSTRING_LEN(salt) < 2) {
|
|
||||||
goto short_salt;
|
|
||||||
}
|
|
||||||
|
|
||||||
s = StringValueCStr(str);
|
s = StringValueCStr(str);
|
||||||
saltp = RSTRING_PTR(salt);
|
saltp = RSTRING_PTR(salt);
|
||||||
if (!saltp[0] || !saltp[1]) goto short_salt;
|
if (RSTRING_LEN(salt) < 2 || !saltp[0] || !saltp[1]) {
|
||||||
|
rb_raise(rb_eArgError, "salt too short (need >=2 bytes)");
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef BROKEN_CRYPT
|
#ifdef BROKEN_CRYPT
|
||||||
if (!ISASCII((unsigned char)saltp[0]) || !ISASCII((unsigned char)saltp[1])) {
|
if (!ISASCII((unsigned char)saltp[0]) || !ISASCII((unsigned char)saltp[1])) {
|
||||||
salt_8bit_clean[0] = saltp[0] & 0x7f;
|
salt_8bit_clean[0] = saltp[0] & 0x7f;
|
||||||
|
@ -9781,10 +9780,6 @@ rb_str_crypt(VALUE str, VALUE salt)
|
||||||
result = rb_str_new_cstr(res);
|
result = rb_str_new_cstr(res);
|
||||||
CRYPT_END();
|
CRYPT_END();
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
short_salt:
|
|
||||||
rb_raise(rb_eArgError, "salt too short (need >=2 bytes)");
|
|
||||||
UNREACHABLE_RETURN(Qundef);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue