mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
* Fail build if compiling extensions raises warnings (#1953) Make warning into errors and also fix all compiler warnings reported in mini_ssl source code. * Fix some compiler warnings and errors reported by checks * Add MAKE_WARNINGS_INTO_ERRORS env variable MAKE_WARNINGS_INTO_ERRORS environment variable toggles whether a build should treat all warnings into errors or not. Move appending WERRORFLAG to cflags after OpenSSL methods verification because on some specifics builds this causes mkmf to wrongly detect methods in OpenSSL headers. * Add noentry to write date to avoid unused variables * Ignore implicit-fallthrough warnings Those warnings are related to ragel state machine generated code. * Enforce no warnings on GH Actions * Update History.md file reflecting latest changes
This commit is contained in:
parent
732383b81f
commit
50185aec02
9 changed files with 86 additions and 52 deletions
4
.github/workflows/mri.yml
vendored
4
.github/workflows/mri.yml
vendored
|
@ -60,6 +60,10 @@ jobs:
|
|||
shell: bash
|
||||
run: echo 'DISABLE_SSL=true' >> $GITHUB_ENV
|
||||
|
||||
- name: set WERRORFLAG
|
||||
shell: bash
|
||||
run: echo 'MAKE_WARNINGS_INTO_ERRORS=true' >> $GITHUB_ENV
|
||||
|
||||
- name: compile
|
||||
run: bundle exec rake compile
|
||||
|
||||
|
|
4
.github/workflows/non_mri.yml
vendored
4
.github/workflows/non_mri.yml
vendored
|
@ -54,6 +54,10 @@ jobs:
|
|||
shell: bash
|
||||
run: echo 'DISABLE_SSL=true' >> $GITHUB_ENV
|
||||
|
||||
- name: set WERRORFLAG
|
||||
shell: bash
|
||||
run: echo 'MAKE_WARNINGS_INTO_ERRORS=true' >> $GITHUB_ENV
|
||||
|
||||
- name: compile
|
||||
run: bundle exec rake compile
|
||||
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
|
||||
* Features
|
||||
* Your feature goes here <Most recent on the top, like GitHub> (#Github Number)
|
||||
* Fail build if compiling extensions raises warnings on GH Actions ([#1953])
|
||||
* Add MAKE_WARNINGS_INTO_ERRORS environment variable to toggle whether a build should treat all warnings into errors or not ([#1953])
|
||||
|
||||
* Bugfixes
|
||||
* Your bugfix goes here <Most recent on the top, like GitHub> (#Github Number)
|
||||
* Fix compiler warnings, but skipped warnings related to ragel state machine generated code ([#1953])
|
||||
|
||||
## 5.1.0 / 2020-11-30
|
||||
|
||||
|
|
|
@ -25,4 +25,15 @@ unless ENV["DISABLE_SSL"]
|
|||
end
|
||||
end
|
||||
|
||||
if ENV["MAKE_WARNINGS_INTO_ERRORS"]
|
||||
# Make all warnings into errors
|
||||
# Except `implicit-fallthrough` since most failures comes from ragel state machine generated code
|
||||
if respond_to? :append_cflags
|
||||
append_cflags config_string 'WERRORFLAG'
|
||||
append_cflags '-Wno-implicit-fallthrough'
|
||||
else
|
||||
$CFLAGS += ' ' << (config_string 'WERRORFLAG') << ' -Wno-implicit-fallthrough'
|
||||
end
|
||||
end
|
||||
|
||||
create_makefile("puma/puma_http11")
|
||||
|
|
|
@ -43,15 +43,13 @@ static const int puma_parser_start = 1;
|
|||
static const int puma_parser_first_final = 46;
|
||||
static const int puma_parser_error = 0;
|
||||
|
||||
static const int puma_parser_en_main = 1;
|
||||
|
||||
|
||||
#line 85 "ext/puma_http11/http11_parser.rl"
|
||||
|
||||
int puma_parser_init(puma_parser *parser) {
|
||||
int cs = 0;
|
||||
|
||||
#line 55 "ext/puma_http11/http11_parser.c"
|
||||
#line 53 "ext/puma_http11/http11_parser.c"
|
||||
{
|
||||
cs = puma_parser_start;
|
||||
}
|
||||
|
@ -85,7 +83,7 @@ size_t puma_parser_execute(puma_parser *parser, const char *buffer, size_t len,
|
|||
assert((size_t) (pe - p) == len - off && "pointers aren't same distance");
|
||||
|
||||
|
||||
#line 89 "ext/puma_http11/http11_parser.c"
|
||||
#line 87 "ext/puma_http11/http11_parser.c"
|
||||
{
|
||||
if ( p == pe )
|
||||
goto _test_eof;
|
||||
|
@ -116,7 +114,7 @@ st2:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof2;
|
||||
case 2:
|
||||
#line 120 "ext/puma_http11/http11_parser.c"
|
||||
#line 118 "ext/puma_http11/http11_parser.c"
|
||||
switch( (*p) ) {
|
||||
case 32: goto tr2;
|
||||
case 36: goto st27;
|
||||
|
@ -141,7 +139,7 @@ st3:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof3;
|
||||
case 3:
|
||||
#line 145 "ext/puma_http11/http11_parser.c"
|
||||
#line 143 "ext/puma_http11/http11_parser.c"
|
||||
switch( (*p) ) {
|
||||
case 42: goto tr4;
|
||||
case 43: goto tr5;
|
||||
|
@ -165,7 +163,7 @@ st4:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof4;
|
||||
case 4:
|
||||
#line 169 "ext/puma_http11/http11_parser.c"
|
||||
#line 167 "ext/puma_http11/http11_parser.c"
|
||||
switch( (*p) ) {
|
||||
case 32: goto tr8;
|
||||
case 35: goto tr9;
|
||||
|
@ -227,7 +225,7 @@ st5:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof5;
|
||||
case 5:
|
||||
#line 231 "ext/puma_http11/http11_parser.c"
|
||||
#line 229 "ext/puma_http11/http11_parser.c"
|
||||
if ( (*p) == 72 )
|
||||
goto tr10;
|
||||
goto st0;
|
||||
|
@ -239,7 +237,7 @@ st6:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof6;
|
||||
case 6:
|
||||
#line 243 "ext/puma_http11/http11_parser.c"
|
||||
#line 241 "ext/puma_http11/http11_parser.c"
|
||||
if ( (*p) == 84 )
|
||||
goto st7;
|
||||
goto st0;
|
||||
|
@ -320,7 +318,7 @@ st14:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof14;
|
||||
case 14:
|
||||
#line 324 "ext/puma_http11/http11_parser.c"
|
||||
#line 322 "ext/puma_http11/http11_parser.c"
|
||||
if ( (*p) == 10 )
|
||||
goto st15;
|
||||
goto st0;
|
||||
|
@ -371,7 +369,7 @@ st46:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof46;
|
||||
case 46:
|
||||
#line 375 "ext/puma_http11/http11_parser.c"
|
||||
#line 373 "ext/puma_http11/http11_parser.c"
|
||||
goto st0;
|
||||
tr21:
|
||||
#line 40 "ext/puma_http11/http11_parser.rl"
|
||||
|
@ -387,7 +385,7 @@ st17:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof17;
|
||||
case 17:
|
||||
#line 391 "ext/puma_http11/http11_parser.c"
|
||||
#line 389 "ext/puma_http11/http11_parser.c"
|
||||
switch( (*p) ) {
|
||||
case 33: goto tr23;
|
||||
case 58: goto tr24;
|
||||
|
@ -426,7 +424,7 @@ st18:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof18;
|
||||
case 18:
|
||||
#line 430 "ext/puma_http11/http11_parser.c"
|
||||
#line 428 "ext/puma_http11/http11_parser.c"
|
||||
switch( (*p) ) {
|
||||
case 13: goto tr26;
|
||||
case 32: goto tr27;
|
||||
|
@ -440,7 +438,7 @@ st19:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof19;
|
||||
case 19:
|
||||
#line 444 "ext/puma_http11/http11_parser.c"
|
||||
#line 442 "ext/puma_http11/http11_parser.c"
|
||||
if ( (*p) == 13 )
|
||||
goto tr29;
|
||||
goto st19;
|
||||
|
@ -486,7 +484,7 @@ st20:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof20;
|
||||
case 20:
|
||||
#line 490 "ext/puma_http11/http11_parser.c"
|
||||
#line 488 "ext/puma_http11/http11_parser.c"
|
||||
switch( (*p) ) {
|
||||
case 32: goto tr31;
|
||||
case 60: goto st0;
|
||||
|
@ -507,7 +505,7 @@ st21:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof21;
|
||||
case 21:
|
||||
#line 511 "ext/puma_http11/http11_parser.c"
|
||||
#line 509 "ext/puma_http11/http11_parser.c"
|
||||
switch( (*p) ) {
|
||||
case 32: goto tr33;
|
||||
case 60: goto st0;
|
||||
|
@ -528,7 +526,7 @@ st22:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof22;
|
||||
case 22:
|
||||
#line 532 "ext/puma_http11/http11_parser.c"
|
||||
#line 530 "ext/puma_http11/http11_parser.c"
|
||||
switch( (*p) ) {
|
||||
case 43: goto st22;
|
||||
case 58: goto st23;
|
||||
|
@ -553,7 +551,7 @@ st23:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof23;
|
||||
case 23:
|
||||
#line 557 "ext/puma_http11/http11_parser.c"
|
||||
#line 555 "ext/puma_http11/http11_parser.c"
|
||||
switch( (*p) ) {
|
||||
case 32: goto tr8;
|
||||
case 34: goto st0;
|
||||
|
@ -573,7 +571,7 @@ st24:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof24;
|
||||
case 24:
|
||||
#line 577 "ext/puma_http11/http11_parser.c"
|
||||
#line 575 "ext/puma_http11/http11_parser.c"
|
||||
switch( (*p) ) {
|
||||
case 32: goto tr37;
|
||||
case 34: goto st0;
|
||||
|
@ -596,7 +594,7 @@ st25:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof25;
|
||||
case 25:
|
||||
#line 600 "ext/puma_http11/http11_parser.c"
|
||||
#line 598 "ext/puma_http11/http11_parser.c"
|
||||
switch( (*p) ) {
|
||||
case 32: goto tr41;
|
||||
case 34: goto st0;
|
||||
|
@ -616,7 +614,7 @@ st26:
|
|||
if ( ++p == pe )
|
||||
goto _test_eof26;
|
||||
case 26:
|
||||
#line 620 "ext/puma_http11/http11_parser.c"
|
||||
#line 618 "ext/puma_http11/http11_parser.c"
|
||||
switch( (*p) ) {
|
||||
case 32: goto tr44;
|
||||
case 34: goto st0;
|
||||
|
|
|
@ -58,7 +58,7 @@ public class Http11Parser {
|
|||
}%%
|
||||
|
||||
/** Data **/
|
||||
%% write data;
|
||||
%% write data noentry;
|
||||
|
||||
public static interface ElementCB {
|
||||
public void call(Ruby runtime, RubyHash data, ByteList buffer, int at, int length);
|
||||
|
|
|
@ -81,7 +81,7 @@ static void snake_upcase_char(char *c)
|
|||
}%%
|
||||
|
||||
/** Data **/
|
||||
%% write data;
|
||||
%% write data noentry;
|
||||
|
||||
int puma_parser_init(puma_parser *parser) {
|
||||
int cs = 0;
|
||||
|
|
|
@ -88,6 +88,10 @@ DH *get_dh1024() {
|
|||
static unsigned char dh1024_g[] = { 0x02 };
|
||||
|
||||
DH *dh;
|
||||
#if !(OPENSSL_VERSION_NUMBER < 0x10100005L || defined(LIBRESSL_VERSION_NUMBER))
|
||||
BIGNUM *p, *g;
|
||||
#endif
|
||||
|
||||
dh = DH_new();
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100005L || defined(LIBRESSL_VERSION_NUMBER)
|
||||
|
@ -99,7 +103,6 @@ DH *get_dh1024() {
|
|||
return NULL;
|
||||
}
|
||||
#else
|
||||
BIGNUM *p, *g;
|
||||
p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
|
||||
g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), NULL);
|
||||
|
||||
|
@ -141,37 +144,48 @@ static int engine_verify_callback(int preverify_ok, X509_STORE_CTX* ctx) {
|
|||
}
|
||||
|
||||
VALUE engine_init_server(VALUE self, VALUE mini_ssl_ctx) {
|
||||
ms_conn* conn;
|
||||
VALUE obj;
|
||||
SSL_CTX* ctx;
|
||||
SSL* ssl;
|
||||
int min, ssl_options;
|
||||
#ifdef HAVE_SSL_CTX_SET_MIN_PROTO_VERSION
|
||||
int min;
|
||||
#endif
|
||||
int ssl_options;
|
||||
ID sym_key, sym_cert, sym_ca, sym_verify_mode, sym_ssl_cipher_filter, sym_no_tlsv1, sym_no_tlsv1_1;
|
||||
VALUE key, cert, ca, verify_mode, ssl_cipher_filter, no_tlsv1, no_tlsv1_1;
|
||||
DH *dh;
|
||||
|
||||
ms_conn* conn = engine_alloc(self, &obj);
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10002000L
|
||||
EC_KEY *ecdh;
|
||||
#endif
|
||||
|
||||
ID sym_key = rb_intern("key");
|
||||
VALUE key = rb_funcall(mini_ssl_ctx, sym_key, 0);
|
||||
conn = engine_alloc(self, &obj);
|
||||
|
||||
sym_key = rb_intern("key");
|
||||
key = rb_funcall(mini_ssl_ctx, sym_key, 0);
|
||||
|
||||
StringValue(key);
|
||||
|
||||
ID sym_cert = rb_intern("cert");
|
||||
VALUE cert = rb_funcall(mini_ssl_ctx, sym_cert, 0);
|
||||
sym_cert = rb_intern("cert");
|
||||
cert = rb_funcall(mini_ssl_ctx, sym_cert, 0);
|
||||
|
||||
StringValue(cert);
|
||||
|
||||
ID sym_ca = rb_intern("ca");
|
||||
VALUE ca = rb_funcall(mini_ssl_ctx, sym_ca, 0);
|
||||
sym_ca = rb_intern("ca");
|
||||
ca = rb_funcall(mini_ssl_ctx, sym_ca, 0);
|
||||
|
||||
ID sym_verify_mode = rb_intern("verify_mode");
|
||||
VALUE verify_mode = rb_funcall(mini_ssl_ctx, sym_verify_mode, 0);
|
||||
sym_verify_mode = rb_intern("verify_mode");
|
||||
verify_mode = rb_funcall(mini_ssl_ctx, sym_verify_mode, 0);
|
||||
|
||||
ID sym_ssl_cipher_filter = rb_intern("ssl_cipher_filter");
|
||||
VALUE ssl_cipher_filter = rb_funcall(mini_ssl_ctx, sym_ssl_cipher_filter, 0);
|
||||
sym_ssl_cipher_filter = rb_intern("ssl_cipher_filter");
|
||||
ssl_cipher_filter = rb_funcall(mini_ssl_ctx, sym_ssl_cipher_filter, 0);
|
||||
|
||||
ID sym_no_tlsv1 = rb_intern("no_tlsv1");
|
||||
VALUE no_tlsv1 = rb_funcall(mini_ssl_ctx, sym_no_tlsv1, 0);
|
||||
sym_no_tlsv1 = rb_intern("no_tlsv1");
|
||||
no_tlsv1 = rb_funcall(mini_ssl_ctx, sym_no_tlsv1, 0);
|
||||
|
||||
ID sym_no_tlsv1_1 = rb_intern("no_tlsv1_1");
|
||||
VALUE no_tlsv1_1 = rb_funcall(mini_ssl_ctx, sym_no_tlsv1_1, 0);
|
||||
sym_no_tlsv1_1 = rb_intern("no_tlsv1_1");
|
||||
no_tlsv1_1 = rb_funcall(mini_ssl_ctx, sym_no_tlsv1_1, 0);
|
||||
|
||||
#ifdef HAVE_TLS_SERVER_METHOD
|
||||
ctx = SSL_CTX_new(TLS_server_method());
|
||||
|
@ -228,13 +242,13 @@ VALUE engine_init_server(VALUE self, VALUE mini_ssl_ctx) {
|
|||
SSL_CTX_set_cipher_list(ctx, "HIGH:!aNULL@STRENGTH");
|
||||
}
|
||||
|
||||
DH *dh = get_dh1024();
|
||||
dh = get_dh1024();
|
||||
SSL_CTX_set_tmp_dh(ctx, dh);
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10002000L
|
||||
// Remove this case if OpenSSL 1.0.1 (now EOL) support is no
|
||||
// longer needed.
|
||||
EC_KEY *ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
|
||||
ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
|
||||
if (ecdh) {
|
||||
SSL_CTX_set_tmp_ecdh(ctx, ecdh);
|
||||
EC_KEY_free(ecdh);
|
||||
|
@ -298,6 +312,8 @@ VALUE engine_inject(VALUE self, VALUE str) {
|
|||
|
||||
static VALUE eError;
|
||||
|
||||
NORETURN(void raise_error(SSL* ssl, int result));
|
||||
|
||||
void raise_error(SSL* ssl, int result) {
|
||||
char buf[512];
|
||||
char msg[512];
|
||||
|
@ -320,8 +336,7 @@ void raise_error(SSL* ssl, int result) {
|
|||
} else {
|
||||
err = (int) ERR_get_error();
|
||||
ERR_error_string_n(err, buf, sizeof(buf));
|
||||
int errexp = err & mask;
|
||||
snprintf(msg, sizeof(msg), "OpenSSL error: %s - %d", buf, errexp);
|
||||
snprintf(msg, sizeof(msg), "OpenSSL error: %s - %d", buf, err & mask);
|
||||
}
|
||||
} else {
|
||||
snprintf(msg, sizeof(msg), "Unknown OpenSSL error: %d", ssl_err);
|
||||
|
@ -552,9 +567,10 @@ void Init_mini_ssl(VALUE puma) {
|
|||
|
||||
#else
|
||||
|
||||
NORETURN(VALUE raise_error(VALUE self));
|
||||
|
||||
VALUE raise_error(VALUE self) {
|
||||
rb_raise(rb_eStandardError, "SSL not available in this build");
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
void Init_mini_ssl(VALUE puma) {
|
||||
|
|
|
@ -182,8 +182,6 @@ static final int puma_parser_start = 1;
|
|||
static final int puma_parser_first_final = 46;
|
||||
static final int puma_parser_error = 0;
|
||||
|
||||
static final int puma_parser_en_main = 1;
|
||||
|
||||
|
||||
// line 62 "ext/puma_http11/http11_parser.java.rl"
|
||||
|
||||
|
@ -212,12 +210,12 @@ static final int puma_parser_en_main = 1;
|
|||
cs = 0;
|
||||
|
||||
|
||||
// line 218 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
|
||||
// line 214 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
|
||||
{
|
||||
cs = puma_parser_start;
|
||||
}
|
||||
|
||||
// line 90 "ext/puma_http11/http11_parser.java.rl"
|
||||
// line 88 "ext/puma_http11/http11_parser.java.rl"
|
||||
|
||||
body_start = 0;
|
||||
content_len = 0;
|
||||
|
@ -244,7 +242,7 @@ static final int puma_parser_en_main = 1;
|
|||
parser.buffer = buffer;
|
||||
|
||||
|
||||
// line 250 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
|
||||
// line 246 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
|
||||
{
|
||||
int _klen;
|
||||
int _trans = 0;
|
||||
|
@ -400,7 +398,7 @@ case 1:
|
|||
{ p += 1; _goto_targ = 5; if (true) continue _goto;}
|
||||
}
|
||||
break;
|
||||
// line 406 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
|
||||
// line 402 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -420,7 +418,7 @@ case 5:
|
|||
break; }
|
||||
}
|
||||
|
||||
// line 116 "ext/puma_http11/http11_parser.java.rl"
|
||||
// line 114 "ext/puma_http11/http11_parser.java.rl"
|
||||
|
||||
parser.cs = cs;
|
||||
parser.nread += (p - off);
|
||||
|
|
Loading…
Add table
Reference in a new issue