summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-02-11 22:24:49 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-02-11 22:25:31 +0900
commit81f17857a7932cd838dd59991b4e6514f39184e6 (patch)
tree66ed1704cf0fc57e3a5a006b1a4f32049b79a2c7 /string.c
parentf3f78f96548e10e76784b2b45771b41dd358afd2 (diff)
Merged too-short salt conditions instead of UNREACHABLE_RETURN
Diffstat (limited to 'string.c')
-rw-r--r--string.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/string.c b/string.c
index c9fdc17258..e52868c80b 100644
--- a/string.c
+++ b/string.c
@@ -9749,13 +9749,12 @@ rb_str_crypt(VALUE str, VALUE salt)
StringValue(salt);
mustnot_wchar(str);
mustnot_wchar(salt);
- if (RSTRING_LEN(salt) < 2) {
- goto short_salt;
- }
-
s = StringValueCStr(str);
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
if (!ISASCII((unsigned char)saltp[0]) || !ISASCII((unsigned char)saltp[1])) {
salt_8bit_clean[0] = saltp[0] & 0x7f;
@@ -9781,10 +9780,6 @@ rb_str_crypt(VALUE str, VALUE salt)
result = rb_str_new_cstr(res);
CRYPT_END();
return result;
-
- short_salt:
- rb_raise(rb_eArgError, "salt too short (need >=2 bytes)");
- UNREACHABLE_RETURN(Qundef);
}