Skip to content

Commit fd39183

Browse files
authored
Merge pull request #413 from ruby/backport-ruby-core
Backport ruby core repo
2 parents a0e98d4 + 9e4d470 commit fd39183

File tree

4 files changed

+45
-47
lines changed

4 files changed

+45
-47
lines changed

ext/openssl/ossl_ssl.c

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,8 +2412,6 @@ ossl_ssl_tmp_key(VALUE self)
24122412
# endif /* defined(HAVE_SSL_GET_SERVER_TMP_KEY) */
24132413
#endif /* !defined(OPENSSL_NO_SOCK) */
24142414

2415-
#undef rb_intern
2416-
#define rb_intern(s) rb_intern_const(s)
24172415
void
24182416
Init_ossl_ssl(void)
24192417
{
@@ -2424,8 +2422,8 @@ Init_ossl_ssl(void)
24242422
rb_mWaitWritable = rb_define_module_under(rb_cIO, "WaitWritable");
24252423
#endif
24262424

2427-
id_call = rb_intern("call");
2428-
ID_callback_state = rb_intern("callback_state");
2425+
id_call = rb_intern_const("call");
2426+
ID_callback_state = rb_intern_const("callback_state");
24292427

24302428
ossl_ssl_ex_vcb_idx = SSL_get_ex_new_index(0, (void *)"ossl_ssl_ex_vcb_idx", 0, 0, 0);
24312429
if (ossl_ssl_ex_vcb_idx < 0)
@@ -2492,37 +2490,37 @@ Init_ossl_ssl(void)
24922490
* The _cert_, _key_, and _extra_chain_cert_ attributes are deprecated.
24932491
* It is recommended to use #add_certificate instead.
24942492
*/
2495-
rb_attr(cSSLContext, rb_intern("cert"), 1, 1, Qfalse);
2493+
rb_attr(cSSLContext, rb_intern_const("cert"), 1, 1, Qfalse);
24962494

24972495
/*
24982496
* Context private key
24992497
*
25002498
* The _cert_, _key_, and _extra_chain_cert_ attributes are deprecated.
25012499
* It is recommended to use #add_certificate instead.
25022500
*/
2503-
rb_attr(cSSLContext, rb_intern("key"), 1, 1, Qfalse);
2501+
rb_attr(cSSLContext, rb_intern_const("key"), 1, 1, Qfalse);
25042502

25052503
/*
25062504
* A certificate or Array of certificates that will be sent to the client.
25072505
*/
2508-
rb_attr(cSSLContext, rb_intern("client_ca"), 1, 1, Qfalse);
2506+
rb_attr(cSSLContext, rb_intern_const("client_ca"), 1, 1, Qfalse);
25092507

25102508
/*
25112509
* The path to a file containing a PEM-format CA certificate
25122510
*/
2513-
rb_attr(cSSLContext, rb_intern("ca_file"), 1, 1, Qfalse);
2511+
rb_attr(cSSLContext, rb_intern_const("ca_file"), 1, 1, Qfalse);
25142512

25152513
/*
25162514
* The path to a directory containing CA certificates in PEM format.
25172515
*
25182516
* Files are looked up by subject's X509 name's hash value.
25192517
*/
2520-
rb_attr(cSSLContext, rb_intern("ca_path"), 1, 1, Qfalse);
2518+
rb_attr(cSSLContext, rb_intern_const("ca_path"), 1, 1, Qfalse);
25212519

25222520
/*
25232521
* Maximum session lifetime in seconds.
25242522
*/
2525-
rb_attr(cSSLContext, rb_intern("timeout"), 1, 1, Qfalse);
2523+
rb_attr(cSSLContext, rb_intern_const("timeout"), 1, 1, Qfalse);
25262524

25272525
/*
25282526
* Session verification mode.
@@ -2535,12 +2533,12 @@ Init_ossl_ssl(void)
25352533
*
25362534
* See SSL_CTX_set_verify(3) for details.
25372535
*/
2538-
rb_attr(cSSLContext, rb_intern("verify_mode"), 1, 1, Qfalse);
2536+
rb_attr(cSSLContext, rb_intern_const("verify_mode"), 1, 1, Qfalse);
25392537

25402538
/*
25412539
* Number of CA certificates to walk when verifying a certificate chain.
25422540
*/
2543-
rb_attr(cSSLContext, rb_intern("verify_depth"), 1, 1, Qfalse);
2541+
rb_attr(cSSLContext, rb_intern_const("verify_depth"), 1, 1, Qfalse);
25442542

25452543
/*
25462544
* A callback for additional certificate verification. The callback is
@@ -2554,20 +2552,20 @@ Init_ossl_ssl(void)
25542552
* If the callback returns +false+, the chain verification is immediately
25552553
* stopped and a bad_certificate alert is then sent.
25562554
*/
2557-
rb_attr(cSSLContext, rb_intern("verify_callback"), 1, 1, Qfalse);
2555+
rb_attr(cSSLContext, rb_intern_const("verify_callback"), 1, 1, Qfalse);
25582556

25592557
/*
25602558
* Whether to check the server certificate is valid for the hostname.
25612559
*
25622560
* In order to make this work, verify_mode must be set to VERIFY_PEER and
25632561
* the server hostname must be given by OpenSSL::SSL::SSLSocket#hostname=.
25642562
*/
2565-
rb_attr(cSSLContext, rb_intern("verify_hostname"), 1, 1, Qfalse);
2563+
rb_attr(cSSLContext, rb_intern_const("verify_hostname"), 1, 1, Qfalse);
25662564

25672565
/*
25682566
* An OpenSSL::X509::Store used for certificate verification.
25692567
*/
2570-
rb_attr(cSSLContext, rb_intern("cert_store"), 1, 1, Qfalse);
2568+
rb_attr(cSSLContext, rb_intern_const("cert_store"), 1, 1, Qfalse);
25712569

25722570
/*
25732571
* An Array of extra X509 certificates to be added to the certificate
@@ -2576,7 +2574,7 @@ Init_ossl_ssl(void)
25762574
* The _cert_, _key_, and _extra_chain_cert_ attributes are deprecated.
25772575
* It is recommended to use #add_certificate instead.
25782576
*/
2579-
rb_attr(cSSLContext, rb_intern("extra_chain_cert"), 1, 1, Qfalse);
2577+
rb_attr(cSSLContext, rb_intern_const("extra_chain_cert"), 1, 1, Qfalse);
25802578

25812579
/*
25822580
* A callback invoked when a client certificate is requested by a server
@@ -2586,14 +2584,14 @@ Init_ossl_ssl(void)
25862584
* containing an OpenSSL::X509::Certificate and an OpenSSL::PKey. If any
25872585
* other value is returned the handshake is suspended.
25882586
*/
2589-
rb_attr(cSSLContext, rb_intern("client_cert_cb"), 1, 1, Qfalse);
2587+
rb_attr(cSSLContext, rb_intern_const("client_cert_cb"), 1, 1, Qfalse);
25902588

25912589
/*
25922590
* Sets the context in which a session can be reused. This allows
25932591
* sessions for multiple applications to be distinguished, for example, by
25942592
* name.
25952593
*/
2596-
rb_attr(cSSLContext, rb_intern("session_id_context"), 1, 1, Qfalse);
2594+
rb_attr(cSSLContext, rb_intern_const("session_id_context"), 1, 1, Qfalse);
25972595

25982596
/*
25992597
* A callback invoked on a server when a session is proposed by the client
@@ -2602,15 +2600,15 @@ Init_ossl_ssl(void)
26022600
* The callback is invoked with the SSLSocket and session id. The
26032601
* callback may return a Session from an external cache.
26042602
*/
2605-
rb_attr(cSSLContext, rb_intern("session_get_cb"), 1, 1, Qfalse);
2603+
rb_attr(cSSLContext, rb_intern_const("session_get_cb"), 1, 1, Qfalse);
26062604

26072605
/*
26082606
* A callback invoked when a new session was negotiated.
26092607
*
26102608
* The callback is invoked with an SSLSocket. If +false+ is returned the
26112609
* session will be removed from the internal cache.
26122610
*/
2613-
rb_attr(cSSLContext, rb_intern("session_new_cb"), 1, 1, Qfalse);
2611+
rb_attr(cSSLContext, rb_intern_const("session_new_cb"), 1, 1, Qfalse);
26142612

26152613
/*
26162614
* A callback invoked when a session is removed from the internal cache.
@@ -2621,7 +2619,7 @@ Init_ossl_ssl(void)
26212619
* multi-threaded application. The callback is called inside a global lock
26222620
* and it can randomly cause deadlock on Ruby thread switching.
26232621
*/
2624-
rb_attr(cSSLContext, rb_intern("session_remove_cb"), 1, 1, Qfalse);
2622+
rb_attr(cSSLContext, rb_intern_const("session_remove_cb"), 1, 1, Qfalse);
26252623

26262624
rb_define_const(mSSLExtConfig, "HAVE_TLSEXT_HOST_NAME", Qtrue);
26272625

@@ -2644,7 +2642,7 @@ Init_ossl_ssl(void)
26442642
* raise RuntimeError, "Client renegotiation disabled"
26452643
* end
26462644
*/
2647-
rb_attr(cSSLContext, rb_intern("renegotiation_cb"), 1, 1, Qfalse);
2645+
rb_attr(cSSLContext, rb_intern_const("renegotiation_cb"), 1, 1, Qfalse);
26482646
#ifndef OPENSSL_NO_NEXTPROTONEG
26492647
/*
26502648
* An Enumerable of Strings. Each String represents a protocol to be
@@ -2657,7 +2655,7 @@ Init_ossl_ssl(void)
26572655
*
26582656
* ctx.npn_protocols = ["http/1.1", "spdy/2"]
26592657
*/
2660-
rb_attr(cSSLContext, rb_intern("npn_protocols"), 1, 1, Qfalse);
2658+
rb_attr(cSSLContext, rb_intern_const("npn_protocols"), 1, 1, Qfalse);
26612659
/*
26622660
* A callback invoked on the client side when the client needs to select
26632661
* a protocol from the list sent by the server. Supported in OpenSSL 1.0.1
@@ -2674,7 +2672,7 @@ Init_ossl_ssl(void)
26742672
* protocols.first
26752673
* end
26762674
*/
2677-
rb_attr(cSSLContext, rb_intern("npn_select_cb"), 1, 1, Qfalse);
2675+
rb_attr(cSSLContext, rb_intern_const("npn_select_cb"), 1, 1, Qfalse);
26782676
#endif
26792677

26802678
#ifdef HAVE_SSL_CTX_SET_ALPN_SELECT_CB
@@ -2689,7 +2687,7 @@ Init_ossl_ssl(void)
26892687
*
26902688
* ctx.alpn_protocols = ["http/1.1", "spdy/2", "h2"]
26912689
*/
2692-
rb_attr(cSSLContext, rb_intern("alpn_protocols"), 1, 1, Qfalse);
2690+
rb_attr(cSSLContext, rb_intern_const("alpn_protocols"), 1, 1, Qfalse);
26932691
/*
26942692
* A callback invoked on the server side when the server needs to select
26952693
* a protocol from the list sent by the client. Supported in OpenSSL 1.0.2
@@ -2706,7 +2704,7 @@ Init_ossl_ssl(void)
27062704
* protocols.first
27072705
* end
27082706
*/
2709-
rb_attr(cSSLContext, rb_intern("alpn_select_cb"), 1, 1, Qfalse);
2707+
rb_attr(cSSLContext, rb_intern_const("alpn_select_cb"), 1, 1, Qfalse);
27102708
#endif
27112709

27122710
rb_define_alias(cSSLContext, "ssl_timeout", "timeout");
@@ -2934,15 +2932,15 @@ Init_ossl_ssl(void)
29342932
#endif
29352933

29362934

2937-
sym_exception = ID2SYM(rb_intern("exception"));
2938-
sym_wait_readable = ID2SYM(rb_intern("wait_readable"));
2939-
sym_wait_writable = ID2SYM(rb_intern("wait_writable"));
2935+
sym_exception = ID2SYM(rb_intern_const("exception"));
2936+
sym_wait_readable = ID2SYM(rb_intern_const("wait_readable"));
2937+
sym_wait_writable = ID2SYM(rb_intern_const("wait_writable"));
29402938

2941-
id_tmp_dh_callback = rb_intern("tmp_dh_callback");
2942-
id_npn_protocols_encoded = rb_intern("npn_protocols_encoded");
2939+
id_tmp_dh_callback = rb_intern_const("tmp_dh_callback");
2940+
id_npn_protocols_encoded = rb_intern_const("npn_protocols_encoded");
29432941

29442942
#define DefIVarID(name) do \
2945-
id_i_##name = rb_intern("@"#name); while (0)
2943+
id_i_##name = rb_intern_const("@"#name); while (0)
29462944

29472945
DefIVarID(cert_store);
29482946
DefIVarID(ca_file);

ext/openssl/ossl_ts.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,24 +1247,24 @@ Init_ossl_ts(void)
12471247
* timestamp server rejects the message imprint algorithm used in the
12481248
* +Request+
12491249
*/
1250-
sBAD_ALG = rb_intern("BAD_ALG");
1250+
sBAD_ALG = rb_intern_const("BAD_ALG");
12511251

12521252
/*
12531253
* Possible return value for +Response#failure_info+. Indicates that the
12541254
* timestamp server was not able to process the +Request+ properly.
12551255
*/
1256-
sBAD_REQUEST = rb_intern("BAD_REQUEST");
1256+
sBAD_REQUEST = rb_intern_const("BAD_REQUEST");
12571257
/*
12581258
* Possible return value for +Response#failure_info+. Indicates that the
12591259
* timestamp server was not able to parse certain data in the +Request+.
12601260
*/
1261-
sBAD_DATA_FORMAT = rb_intern("BAD_DATA_FORMAT");
1261+
sBAD_DATA_FORMAT = rb_intern_const("BAD_DATA_FORMAT");
12621262

1263-
sTIME_NOT_AVAILABLE = rb_intern("TIME_NOT_AVAILABLE");
1264-
sUNACCEPTED_POLICY = rb_intern("UNACCEPTED_POLICY");
1265-
sUNACCEPTED_EXTENSION = rb_intern("UNACCEPTED_EXTENSION");
1266-
sADD_INFO_NOT_AVAILABLE = rb_intern("ADD_INFO_NOT_AVAILABLE");
1267-
sSYSTEM_FAILURE = rb_intern("SYSTEM_FAILURE");
1263+
sTIME_NOT_AVAILABLE = rb_intern_const("TIME_NOT_AVAILABLE");
1264+
sUNACCEPTED_POLICY = rb_intern_const("UNACCEPTED_POLICY");
1265+
sUNACCEPTED_EXTENSION = rb_intern_const("UNACCEPTED_EXTENSION");
1266+
sADD_INFO_NOT_AVAILABLE = rb_intern_const("ADD_INFO_NOT_AVAILABLE");
1267+
sSYSTEM_FAILURE = rb_intern_const("SYSTEM_FAILURE");
12681268

12691269
/* Document-class: OpenSSL::Timestamp
12701270
* Provides classes and methods to request, create and validate
@@ -1503,11 +1503,11 @@ Init_ossl_ts(void)
15031503
*
15041504
*/
15051505
cTimestampFactory = rb_define_class_under(mTimestamp, "Factory", rb_cObject);
1506-
rb_attr(cTimestampFactory, rb_intern("allowed_digests"), 1, 1, 0);
1507-
rb_attr(cTimestampFactory, rb_intern("default_policy_id"), 1, 1, 0);
1508-
rb_attr(cTimestampFactory, rb_intern("serial_number"), 1, 1, 0);
1509-
rb_attr(cTimestampFactory, rb_intern("gen_time"), 1, 1, 0);
1510-
rb_attr(cTimestampFactory, rb_intern("additional_certs"), 1, 1, 0);
1506+
rb_attr(cTimestampFactory, rb_intern_const("allowed_digests"), 1, 1, 0);
1507+
rb_attr(cTimestampFactory, rb_intern_const("default_policy_id"), 1, 1, 0);
1508+
rb_attr(cTimestampFactory, rb_intern_const("serial_number"), 1, 1, 0);
1509+
rb_attr(cTimestampFactory, rb_intern_const("gen_time"), 1, 1, 0);
1510+
rb_attr(cTimestampFactory, rb_intern_const("additional_certs"), 1, 1, 0);
15111511
rb_define_method(cTimestampFactory, "create_timestamp", ossl_tsfac_create_ts, 3);
15121512
}
15131513

lib/openssl/buffering.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def initialize
3131

3232
force_encoding(BINARY)
3333
end
34-
34+
3535
def << string
3636
if string.encoding == BINARY
3737
super(string)

lib/openssl/ssl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ module SocketForwarder
238238
def fileno
239239
to_io.fileno
240240
end
241-
241+
242242
def addr
243243
to_io.addr
244244
end

0 commit comments

Comments
 (0)