[前][次][番号順一覧][スレッド一覧]

ruby-changes:65239

From: Nobuyoshi <ko1@a...>
Date: Thu, 11 Feb 2021 22:28:21 +0900 (JST)
Subject: [ruby-changes:65239] 81f17857a7 (master): Merged too-short salt conditions instead of UNREACHABLE_RETURN

https://git.ruby-lang.org/ruby.git/commit/?id=81f17857a7

From 81f17857a7932cd838dd59991b4e6514f39184e6 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 11 Feb 2021 22:24:49 +0900
Subject: Merged too-short salt conditions instead of UNREACHABLE_RETURN

---
 string.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/string.c b/string.c
index c9fdc17..e52868c 100644
--- a/string.c
+++ b/string.c
@@ -9749,13 +9749,12 @@ rb_str_crypt(VALUE str, VALUE salt) https://github.com/ruby/ruby/blob/trunk/string.c#L9749
     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) https://github.com/ruby/ruby/blob/trunk/string.c#L9780
     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);
 }
 
 
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]