puma 4.3.0 → 4.3.11

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puma might be problematic. Click here for more details.

Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +48 -4
  3. data/LICENSE +0 -0
  4. data/README.md +0 -0
  5. data/bin/puma-wild +0 -0
  6. data/docs/architecture.md +0 -0
  7. data/docs/deployment.md +0 -0
  8. data/docs/images/puma-connection-flow-no-reactor.png +0 -0
  9. data/docs/images/puma-connection-flow.png +0 -0
  10. data/docs/images/puma-general-arch.png +0 -0
  11. data/docs/nginx.md +0 -0
  12. data/docs/plugins.md +0 -0
  13. data/docs/restart.md +0 -0
  14. data/docs/signals.md +0 -0
  15. data/docs/systemd.md +0 -0
  16. data/docs/tcp_mode.md +0 -0
  17. data/ext/puma_http11/PumaHttp11Service.java +0 -0
  18. data/ext/puma_http11/ext_help.h +0 -0
  19. data/ext/puma_http11/extconf.rb +1 -1
  20. data/ext/puma_http11/http11_parser.c +26 -11
  21. data/ext/puma_http11/http11_parser.h +0 -0
  22. data/ext/puma_http11/http11_parser.java.rl +0 -0
  23. data/ext/puma_http11/http11_parser.rl +3 -1
  24. data/ext/puma_http11/http11_parser_common.rl +1 -1
  25. data/ext/puma_http11/io_buffer.c +0 -0
  26. data/ext/puma_http11/mini_ssl.c +0 -0
  27. data/ext/puma_http11/org/jruby/puma/Http11.java +0 -0
  28. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +48 -46
  29. data/ext/puma_http11/org/jruby/puma/IOBuffer.java +0 -0
  30. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +0 -0
  31. data/ext/puma_http11/puma_http11.c +1 -0
  32. data/lib/puma/accept_nonblock.rb +0 -0
  33. data/lib/puma/app/status.rb +4 -2
  34. data/lib/puma/binder.rb +0 -0
  35. data/lib/puma/cli.rb +0 -0
  36. data/lib/puma/client.rb +31 -11
  37. data/lib/puma/cluster.rb +0 -0
  38. data/lib/puma/commonlogger.rb +0 -0
  39. data/lib/puma/configuration.rb +0 -0
  40. data/lib/puma/const.rb +9 -1
  41. data/lib/puma/control_cli.rb +0 -0
  42. data/lib/puma/detect.rb +0 -0
  43. data/lib/puma/dsl.rb +0 -0
  44. data/lib/puma/events.rb +0 -0
  45. data/lib/puma/io_buffer.rb +0 -0
  46. data/lib/puma/jruby_restart.rb +0 -0
  47. data/lib/puma/launcher.rb +0 -0
  48. data/lib/puma/minissl/context_builder.rb +0 -0
  49. data/lib/puma/minissl.rb +0 -0
  50. data/lib/puma/null_io.rb +0 -0
  51. data/lib/puma/plugin/tmp_restart.rb +0 -0
  52. data/lib/puma/plugin.rb +0 -0
  53. data/lib/puma/rack/builder.rb +0 -0
  54. data/lib/puma/rack/urlmap.rb +0 -0
  55. data/lib/puma/rack_default.rb +0 -0
  56. data/lib/puma/reactor.rb +0 -0
  57. data/lib/puma/runner.rb +0 -0
  58. data/lib/puma/server.rb +66 -5
  59. data/lib/puma/single.rb +0 -0
  60. data/lib/puma/state_file.rb +0 -0
  61. data/lib/puma/tcp_logger.rb +0 -0
  62. data/lib/puma/thread_pool.rb +0 -0
  63. data/lib/puma/util.rb +0 -0
  64. data/lib/puma.rb +0 -0
  65. data/lib/rack/handler/puma.rb +0 -0
  66. data/tools/docker/Dockerfile +0 -0
  67. data/tools/jungle/README.md +0 -0
  68. data/tools/jungle/init.d/README.md +0 -0
  69. data/tools/jungle/rc.d/README.md +0 -0
  70. data/tools/jungle/rc.d/puma.conf +0 -0
  71. data/tools/jungle/upstart/README.md +0 -0
  72. data/tools/jungle/upstart/puma-manager.conf +0 -0
  73. data/tools/jungle/upstart/puma.conf +0 -0
  74. data/tools/trickletest.rb +0 -0
  75. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2ba02cb19976145aa1824079a79d468fad878ca58bdb902f60a58b184049714
4
- data.tar.gz: fcfa744db7db86e4acfbfb3d14659ec4aefa86ec249f6105ea7c54d97e361e97
3
+ metadata.gz: f01631d0dd0843d149b6af364b95378f66e93b20ca449e8a734c445cfc74a9b9
4
+ data.tar.gz: 38ff0fb797898ba2981bfe201ce279400151e2c77d1741f028bcb168fe825bd8
5
5
  SHA512:
6
- metadata.gz: 875da8dd65d1c85f3912988c0b8b371fcfe1ef2cc99dbb9d4108c2141c2a0427a3db2cca684e82f5b955c564785d3e49f3723aeb64264d76cc4395ec7da2815c
7
- data.tar.gz: 7460c59d0ec3d2c1733fafd35a33c434385da60b70e325f6c85aeeb2ccdea25e07c2b16f7f08f7cc14cccdf44780d5d5f98b1581fb3565e3557dbfb844e4a332
6
+ metadata.gz: 4f712a8da3d29f6890321a468d49bb9eb104063d6c49ea27ce58101538b1f99180bd4c7a8f96817cf20e1a42b00e8043d760126e9cc899fe335fbddeb6462f45
7
+ data.tar.gz: 4bf8d5bc37ab8f45452967a3bb6c4f30e712c5a73ebaf86db82367dddd4766de651410c29295c292c4bc6b06dffd042c0bf4d3f6acf4c92e0abba6a106b8e43c
data/History.md CHANGED
@@ -1,10 +1,54 @@
1
- ## Master
1
+ ## 4.3.11 / 2022-02-11
2
2
 
3
- * Features
4
- * Your feature goes here (#Github Number)
3
+ * Security
4
+ * Always close the response body (GHSA-rmj8-8hhh-gv5h)
5
+
6
+ ## 4.3.10 / 2021-10-12
5
7
 
6
8
  * Bugfixes
7
- * Your bugfix goes here (#Github Number)
9
+ * Allow UTF-8 in HTTP header values
10
+
11
+ ## 4.3.9 / 2021-10-12
12
+
13
+ * Security
14
+ * Do not allow LF as a line ending in a header (CVE-2021-41136)
15
+
16
+ ## 4.3.8 / 2021-05-11
17
+
18
+ * Security
19
+ * Close keepalive connections after the maximum number of fast inlined requests (#2625)
20
+
21
+ ## 4.3.7 / 2020-11-30
22
+
23
+ * Bugfixes
24
+ * Backport set CONTENT_LENGTH for chunked requests (Originally: #2287, backport: #2496)
25
+
26
+ ## 4.3.6 / 2020-09-05
27
+
28
+ * Bugfixes
29
+ * Explicitly include ctype.h to fix compilation warning and build error on macOS with Xcode 12 (#2304)
30
+ * Don't require json at boot (#2269)
31
+ * Set `CONTENT_LENGTH` for chunked requests (#2287)
32
+
33
+ ## 4.3.4/4.3.5 and 3.12.5/3.12.6 / 2020-05-22
34
+
35
+ Each patchlevel release contains a separate security fix. We recommend simply upgrading to 4.3.5/3.12.6.
36
+
37
+ ## 4.3.3 and 3.12.4 / 2020-02-28
38
+ * Bugfixes
39
+ * Fix: Fixes a problem where we weren't splitting headers correctly on newlines (#2132)
40
+ * Security
41
+ * Fix: Prevent HTTP Response splitting via CR in early hints.
42
+
43
+ ## 4.3.2 and 3.12.3 / 2020-02-27
44
+
45
+ * Security
46
+ * Fix: Prevent HTTP Response splitting via CR/LF in header values. CVE-2020-5247.
47
+
48
+ ## 4.3.1 and 3.12.2 / 2019-12-05
49
+
50
+ * Security
51
+ * Fix: a poorly-behaved client could use keepalive requests to monopolize Puma's reactor and create a denial of service attack. CVE-2019-16770.
8
52
 
9
53
  ## 4.3.0 / 2019-11-07
10
54
 
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
File without changes
data/bin/puma-wild CHANGED
File without changes
data/docs/architecture.md CHANGED
File without changes
data/docs/deployment.md CHANGED
File without changes
File without changes
File without changes
File without changes
data/docs/nginx.md CHANGED
File without changes
data/docs/plugins.md CHANGED
File without changes
data/docs/restart.md CHANGED
File without changes
data/docs/signals.md CHANGED
File without changes
data/docs/systemd.md CHANGED
File without changes
data/docs/tcp_mode.md CHANGED
File without changes
File without changes
File without changes
@@ -1,7 +1,7 @@
1
1
  require 'mkmf'
2
2
 
3
3
  dir_config("puma_http11")
4
- if RUBY_PLATFORM[/mingw32/]
4
+ if $mingw && RUBY_VERSION >= '2.4'
5
5
  append_cflags '-D_FORTIFY_SOURCE=2'
6
6
  append_ldflags '-fstack-protector'
7
7
  have_library 'ssp'
@@ -14,12 +14,14 @@
14
14
 
15
15
  /*
16
16
  * capitalizes all lower-case ASCII characters,
17
- * converts dashes to underscores.
17
+ * converts dashes to underscores, and underscores to commas.
18
18
  */
19
19
  static void snake_upcase_char(char *c)
20
20
  {
21
21
  if (*c >= 'a' && *c <= 'z')
22
22
  *c &= ~0x20;
23
+ else if (*c == '_')
24
+ *c = ',';
23
25
  else if (*c == '-')
24
26
  *c = '_';
25
27
  }
@@ -428,7 +430,13 @@ case 18:
428
430
  switch( (*p) ) {
429
431
  case 13: goto tr26;
430
432
  case 32: goto tr27;
433
+ case 127: goto st0;
431
434
  }
435
+ if ( (*p) > 8 ) {
436
+ if ( 10 <= (*p) && (*p) <= 31 )
437
+ goto st0;
438
+ } else if ( (*p) >= 0 )
439
+ goto st0;
432
440
  goto tr25;
433
441
  tr25:
434
442
  #line 44 "ext/puma_http11/http11_parser.rl"
@@ -438,9 +446,16 @@ st19:
438
446
  if ( ++p == pe )
439
447
  goto _test_eof19;
440
448
  case 19:
441
- #line 442 "ext/puma_http11/http11_parser.c"
442
- if ( (*p) == 13 )
443
- goto tr29;
449
+ #line 448 "ext/puma_http11/http11_parser.c"
450
+ switch( (*p) ) {
451
+ case 13: goto tr29;
452
+ case 127: goto st0;
453
+ }
454
+ if ( (*p) > 8 ) {
455
+ if ( 10 <= (*p) && (*p) <= 31 )
456
+ goto st0;
457
+ } else if ( (*p) >= 0 )
458
+ goto st0;
444
459
  goto st19;
445
460
  tr9:
446
461
  #line 51 "ext/puma_http11/http11_parser.rl"
@@ -484,7 +499,7 @@ st20:
484
499
  if ( ++p == pe )
485
500
  goto _test_eof20;
486
501
  case 20:
487
- #line 488 "ext/puma_http11/http11_parser.c"
502
+ #line 501 "ext/puma_http11/http11_parser.c"
488
503
  switch( (*p) ) {
489
504
  case 32: goto tr31;
490
505
  case 60: goto st0;
@@ -505,7 +520,7 @@ st21:
505
520
  if ( ++p == pe )
506
521
  goto _test_eof21;
507
522
  case 21:
508
- #line 509 "ext/puma_http11/http11_parser.c"
523
+ #line 522 "ext/puma_http11/http11_parser.c"
509
524
  switch( (*p) ) {
510
525
  case 32: goto tr33;
511
526
  case 60: goto st0;
@@ -526,7 +541,7 @@ st22:
526
541
  if ( ++p == pe )
527
542
  goto _test_eof22;
528
543
  case 22:
529
- #line 530 "ext/puma_http11/http11_parser.c"
544
+ #line 543 "ext/puma_http11/http11_parser.c"
530
545
  switch( (*p) ) {
531
546
  case 43: goto st22;
532
547
  case 58: goto st23;
@@ -551,7 +566,7 @@ st23:
551
566
  if ( ++p == pe )
552
567
  goto _test_eof23;
553
568
  case 23:
554
- #line 555 "ext/puma_http11/http11_parser.c"
569
+ #line 568 "ext/puma_http11/http11_parser.c"
555
570
  switch( (*p) ) {
556
571
  case 32: goto tr8;
557
572
  case 34: goto st0;
@@ -571,7 +586,7 @@ st24:
571
586
  if ( ++p == pe )
572
587
  goto _test_eof24;
573
588
  case 24:
574
- #line 575 "ext/puma_http11/http11_parser.c"
589
+ #line 588 "ext/puma_http11/http11_parser.c"
575
590
  switch( (*p) ) {
576
591
  case 32: goto tr37;
577
592
  case 34: goto st0;
@@ -594,7 +609,7 @@ st25:
594
609
  if ( ++p == pe )
595
610
  goto _test_eof25;
596
611
  case 25:
597
- #line 598 "ext/puma_http11/http11_parser.c"
612
+ #line 611 "ext/puma_http11/http11_parser.c"
598
613
  switch( (*p) ) {
599
614
  case 32: goto tr41;
600
615
  case 34: goto st0;
@@ -614,7 +629,7 @@ st26:
614
629
  if ( ++p == pe )
615
630
  goto _test_eof26;
616
631
  case 26:
617
- #line 618 "ext/puma_http11/http11_parser.c"
632
+ #line 631 "ext/puma_http11/http11_parser.c"
618
633
  switch( (*p) ) {
619
634
  case 32: goto tr44;
620
635
  case 34: goto st0;
File without changes
File without changes
@@ -12,12 +12,14 @@
12
12
 
13
13
  /*
14
14
  * capitalizes all lower-case ASCII characters,
15
- * converts dashes to underscores.
15
+ * converts dashes to underscores, and underscores to commas.
16
16
  */
17
17
  static void snake_upcase_char(char *c)
18
18
  {
19
19
  if (*c >= 'a' && *c <= 'z')
20
20
  *c &= ~0x20;
21
+ else if (*c == '_')
22
+ *c = ',';
21
23
  else if (*c == '-')
22
24
  *c = '_';
23
25
  }
@@ -43,7 +43,7 @@
43
43
 
44
44
  field_name = ( token -- ":" )+ >start_field $snake_upcase_field %write_field;
45
45
 
46
- field_value = any* >start_value %write_value;
46
+ field_value = ( (any -- CTL) | "\t" )* >start_value %write_value;
47
47
 
48
48
  message_header = field_name ":" " "* field_value :> CRLF;
49
49
 
File without changes
File without changes
File without changes
@@ -34,9 +34,9 @@ private static short[] init__puma_parser_key_offsets_0()
34
34
  {
35
35
  return new short [] {
36
36
  0, 0, 8, 17, 27, 29, 30, 31, 32, 33, 34, 36,
37
- 39, 41, 44, 45, 61, 62, 78, 80, 81, 89, 97, 107,
38
- 115, 124, 132, 140, 149, 158, 167, 176, 185, 194, 203, 212,
39
- 221, 230, 239, 248, 257, 266, 275, 284, 293, 302, 303
37
+ 39, 41, 44, 45, 61, 62, 78, 85, 91, 99, 107, 117,
38
+ 125, 134, 142, 150, 159, 168, 177, 186, 195, 204, 213, 222,
39
+ 231, 240, 249, 258, 267, 276, 285, 294, 303, 312, 313
40
40
  };
41
41
  }
42
42
 
@@ -52,26 +52,27 @@ private static char[] init__puma_parser_trans_keys_0()
52
52
  46, 48, 57, 48, 57, 13, 48, 57, 10, 13, 33, 124,
53
53
  126, 35, 39, 42, 43, 45, 46, 48, 57, 65, 90, 94,
54
54
  122, 10, 33, 58, 124, 126, 35, 39, 42, 43, 45, 46,
55
- 48, 57, 65, 90, 94, 122, 13, 32, 13, 32, 60, 62,
56
- 127, 0, 31, 34, 35, 32, 60, 62, 127, 0, 31, 34,
57
- 35, 43, 58, 45, 46, 48, 57, 65, 90, 97, 122, 32,
58
- 34, 35, 60, 62, 127, 0, 31, 32, 34, 35, 60, 62,
59
- 63, 127, 0, 31, 32, 34, 35, 60, 62, 127, 0, 31,
60
- 32, 34, 35, 60, 62, 127, 0, 31, 32, 36, 95, 45,
61
- 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57,
62
- 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32,
63
- 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45,
64
- 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57,
65
- 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32,
66
- 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45,
67
- 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57,
68
- 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32,
69
- 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45,
70
- 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57,
71
- 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32,
72
- 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45,
73
- 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57,
74
- 65, 90, 32, 0
55
+ 48, 57, 65, 90, 94, 122, 13, 32, 127, 0, 8, 10,
56
+ 31, 13, 127, 0, 8, 10, 31, 32, 60, 62, 127, 0,
57
+ 31, 34, 35, 32, 60, 62, 127, 0, 31, 34, 35, 43,
58
+ 58, 45, 46, 48, 57, 65, 90, 97, 122, 32, 34, 35,
59
+ 60, 62, 127, 0, 31, 32, 34, 35, 60, 62, 63, 127,
60
+ 0, 31, 32, 34, 35, 60, 62, 127, 0, 31, 32, 34,
61
+ 35, 60, 62, 127, 0, 31, 32, 36, 95, 45, 46, 48,
62
+ 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90,
63
+ 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95,
64
+ 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48,
65
+ 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90,
66
+ 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95,
67
+ 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48,
68
+ 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90,
69
+ 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95,
70
+ 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48,
71
+ 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90,
72
+ 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95,
73
+ 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48,
74
+ 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90,
75
+ 32, 0
75
76
  };
76
77
  }
77
78
 
@@ -82,7 +83,7 @@ private static byte[] init__puma_parser_single_lengths_0()
82
83
  {
83
84
  return new byte [] {
84
85
  0, 2, 3, 4, 2, 1, 1, 1, 1, 1, 0, 1,
85
- 0, 1, 1, 4, 1, 4, 2, 1, 4, 4, 2, 6,
86
+ 0, 1, 1, 4, 1, 4, 3, 2, 4, 4, 2, 6,
86
87
  7, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3,
87
88
  3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 0
88
89
  };
@@ -95,7 +96,7 @@ private static byte[] init__puma_parser_range_lengths_0()
95
96
  {
96
97
  return new byte [] {
97
98
  0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1,
98
- 1, 1, 0, 6, 0, 6, 0, 0, 2, 2, 4, 1,
99
+ 1, 1, 0, 6, 0, 6, 2, 2, 2, 2, 4, 1,
99
100
  1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3,
100
101
  3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0
101
102
  };
@@ -108,9 +109,9 @@ private static short[] init__puma_parser_index_offsets_0()
108
109
  {
109
110
  return new short [] {
110
111
  0, 0, 6, 13, 21, 24, 26, 28, 30, 32, 34, 36,
111
- 39, 41, 44, 46, 57, 59, 70, 73, 75, 82, 89, 96,
112
- 104, 113, 121, 129, 136, 143, 150, 157, 164, 171, 178, 185,
113
- 192, 199, 206, 213, 220, 227, 234, 241, 248, 255, 257
112
+ 39, 41, 44, 46, 57, 59, 70, 76, 81, 88, 95, 102,
113
+ 110, 119, 127, 135, 142, 149, 156, 163, 170, 177, 184, 191,
114
+ 198, 205, 212, 219, 226, 233, 240, 247, 254, 261, 263
114
115
  };
115
116
  }
116
117
 
@@ -126,22 +127,23 @@ private static byte[] init__puma_parser_indicies_0()
126
127
  16, 15, 1, 17, 1, 18, 17, 1, 19, 1, 20, 21,
127
128
  21, 21, 21, 21, 21, 21, 21, 21, 1, 22, 1, 23,
128
129
  24, 23, 23, 23, 23, 23, 23, 23, 23, 1, 26, 27,
129
- 25, 29, 28, 30, 1, 1, 1, 1, 1, 31, 32, 1,
130
- 1, 1, 1, 1, 33, 34, 35, 34, 34, 34, 34, 1,
131
- 8, 1, 9, 1, 1, 1, 1, 35, 36, 1, 38, 1,
132
- 1, 39, 1, 1, 37, 40, 1, 42, 1, 1, 1, 1,
133
- 41, 43, 1, 45, 1, 1, 1, 1, 44, 2, 46, 46,
134
- 46, 46, 46, 1, 2, 47, 47, 47, 47, 47, 1, 2,
135
- 48, 48, 48, 48, 48, 1, 2, 49, 49, 49, 49, 49,
136
- 1, 2, 50, 50, 50, 50, 50, 1, 2, 51, 51, 51,
137
- 51, 51, 1, 2, 52, 52, 52, 52, 52, 1, 2, 53,
138
- 53, 53, 53, 53, 1, 2, 54, 54, 54, 54, 54, 1,
139
- 2, 55, 55, 55, 55, 55, 1, 2, 56, 56, 56, 56,
140
- 56, 1, 2, 57, 57, 57, 57, 57, 1, 2, 58, 58,
141
- 58, 58, 58, 1, 2, 59, 59, 59, 59, 59, 1, 2,
142
- 60, 60, 60, 60, 60, 1, 2, 61, 61, 61, 61, 61,
143
- 1, 2, 62, 62, 62, 62, 62, 1, 2, 63, 63, 63,
144
- 63, 63, 1, 2, 1, 1, 0
130
+ 1, 1, 1, 25, 29, 1, 1, 1, 28, 30, 1, 1,
131
+ 1, 1, 1, 31, 32, 1, 1, 1, 1, 1, 33, 34,
132
+ 35, 34, 34, 34, 34, 1, 8, 1, 9, 1, 1, 1,
133
+ 1, 35, 36, 1, 38, 1, 1, 39, 1, 1, 37, 40,
134
+ 1, 42, 1, 1, 1, 1, 41, 43, 1, 45, 1, 1,
135
+ 1, 1, 44, 2, 46, 46, 46, 46, 46, 1, 2, 47,
136
+ 47, 47, 47, 47, 1, 2, 48, 48, 48, 48, 48, 1,
137
+ 2, 49, 49, 49, 49, 49, 1, 2, 50, 50, 50, 50,
138
+ 50, 1, 2, 51, 51, 51, 51, 51, 1, 2, 52, 52,
139
+ 52, 52, 52, 1, 2, 53, 53, 53, 53, 53, 1, 2,
140
+ 54, 54, 54, 54, 54, 1, 2, 55, 55, 55, 55, 55,
141
+ 1, 2, 56, 56, 56, 56, 56, 1, 2, 57, 57, 57,
142
+ 57, 57, 1, 2, 58, 58, 58, 58, 58, 1, 2, 59,
143
+ 59, 59, 59, 59, 1, 2, 60, 60, 60, 60, 60, 1,
144
+ 2, 61, 61, 61, 61, 61, 1, 2, 62, 62, 62, 62,
145
+ 62, 1, 2, 63, 63, 63, 63, 63, 1, 2, 1, 1,
146
+ 0
145
147
  };
146
148
  }
147
149
 
@@ -217,7 +219,7 @@ static final int puma_parser_en_main = 1;
217
219
  cs = puma_parser_start;
218
220
  }
219
221
 
220
- // line 90 "ext/puma_http11/http11_parser.java.rl"
222
+ // line 88 "ext/puma_http11/http11_parser.java.rl"
221
223
 
222
224
  body_start = 0;
223
225
  content_len = 0;
@@ -420,7 +422,7 @@ case 5:
420
422
  break; }
421
423
  }
422
424
 
423
- // line 116 "ext/puma_http11/http11_parser.java.rl"
425
+ // line 114 "ext/puma_http11/http11_parser.java.rl"
424
426
 
425
427
  parser.cs = cs;
426
428
  parser.nread += (p - off);
File without changes
File without changes
@@ -10,6 +10,7 @@
10
10
  #include "ext_help.h"
11
11
  #include <assert.h>
12
12
  #include <string.h>
13
+ #include <ctype.h>
13
14
  #include "http11_parser.h"
14
15
 
15
16
  #ifndef MANAGED_STRINGS
File without changes
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'json'
4
-
5
3
  module Puma
6
4
  module App
7
5
  # Check out {#call}'s source code to see what actions this web application
@@ -19,6 +17,10 @@ module Puma
19
17
  return rack_response(403, 'Invalid auth token', 'text/plain')
20
18
  end
21
19
 
20
+ if env['PATH_INFO'] =~ /\/(gc-stats|stats|thread-backtraces)$/
21
+ require 'json'
22
+ end
23
+
22
24
  case env['PATH_INFO']
23
25
  when /\/stop$/
24
26
  @cli.stop
data/lib/puma/binder.rb CHANGED
File without changes
data/lib/puma/cli.rb CHANGED
File without changes
data/lib/puma/client.rb CHANGED
@@ -153,7 +153,7 @@ module Puma
153
153
 
154
154
  begin
155
155
  data = @io.read_nonblock(CHUNK_SIZE)
156
- rescue Errno::EAGAIN
156
+ rescue IO::WaitReadable
157
157
  return false
158
158
  rescue SystemCallError, IOError, EOFError
159
159
  raise ConnectionError, "Connection error detected during read"
@@ -285,8 +285,16 @@ module Puma
285
285
 
286
286
  te = @env[TRANSFER_ENCODING2]
287
287
 
288
- if te && CHUNKED.casecmp(te) == 0
289
- return setup_chunked_body(body)
288
+ if te
289
+ if te.include?(",")
290
+ te.split(",").each do |part|
291
+ if CHUNKED.casecmp(part.strip) == 0
292
+ return setup_chunked_body(body)
293
+ end
294
+ end
295
+ elsif CHUNKED.casecmp(te) == 0
296
+ return setup_chunked_body(body)
297
+ end
290
298
  end
291
299
 
292
300
  @chunked_body = false
@@ -343,7 +351,7 @@ module Puma
343
351
 
344
352
  begin
345
353
  chunk = @io.read_nonblock(want)
346
- rescue Errno::EAGAIN
354
+ rescue IO::WaitReadable
347
355
  return false
348
356
  rescue SystemCallError, IOError
349
357
  raise ConnectionError, "Connection error detected during read"
@@ -389,7 +397,10 @@ module Puma
389
397
  raise EOFError
390
398
  end
391
399
 
392
- return true if decode_chunk(chunk)
400
+ if decode_chunk(chunk)
401
+ @env[CONTENT_LENGTH] = @chunked_content_length
402
+ return true
403
+ end
393
404
  end
394
405
  end
395
406
 
@@ -402,19 +413,28 @@ module Puma
402
413
  @body.binmode
403
414
  @tempfile = @body
404
415
 
405
- return decode_chunk(body)
416
+ @chunked_content_length = 0
417
+
418
+ if decode_chunk(body)
419
+ @env[CONTENT_LENGTH] = @chunked_content_length
420
+ return true
421
+ end
422
+ end
423
+
424
+ def write_chunk(str)
425
+ @chunked_content_length += @body.write(str)
406
426
  end
407
427
 
408
428
  def decode_chunk(chunk)
409
429
  if @partial_part_left > 0
410
430
  if @partial_part_left <= chunk.size
411
431
  if @partial_part_left > 2
412
- @body << chunk[0..(@partial_part_left-3)] # skip the \r\n
432
+ write_chunk(chunk[0..(@partial_part_left-3)]) # skip the \r\n
413
433
  end
414
434
  chunk = chunk[@partial_part_left..-1]
415
435
  @partial_part_left = 0
416
436
  else
417
- @body << chunk if @partial_part_left > 2 # don't include the last \r\n
437
+ write_chunk(chunk) if @partial_part_left > 2 # don't include the last \r\n
418
438
  @partial_part_left -= chunk.size
419
439
  return false
420
440
  end
@@ -461,12 +481,12 @@ module Puma
461
481
 
462
482
  case
463
483
  when got == len
464
- @body << part[0..-3] # to skip the ending \r\n
484
+ write_chunk(part[0..-3]) # to skip the ending \r\n
465
485
  when got <= len - 2
466
- @body << part
486
+ write_chunk(part)
467
487
  @partial_part_left = len - part.size
468
488
  when got == len - 1 # edge where we get just \r but not \n
469
- @body << part[0..-2]
489
+ write_chunk(part[0..-2])
470
490
  @partial_part_left = len - part.size
471
491
  end
472
492
  else
data/lib/puma/cluster.rb CHANGED
File without changes
File without changes
File without changes
data/lib/puma/const.rb CHANGED
@@ -100,7 +100,7 @@ module Puma
100
100
  # too taxing on performance.
101
101
  module Const
102
102
 
103
- PUMA_VERSION = VERSION = "4.3.0".freeze
103
+ PUMA_VERSION = VERSION = "4.3.11".freeze
104
104
  CODE_NAME = "Mysterious Traveller".freeze
105
105
  PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze
106
106
 
@@ -118,6 +118,13 @@ module Puma
118
118
  # sending data back
119
119
  WRITE_TIMEOUT = 10
120
120
 
121
+ # How many requests to attempt inline before sending a client back to
122
+ # the reactor to be subject to normal ordering. The idea here is that
123
+ # we amortize the cost of going back to the reactor for a well behaved
124
+ # but very "greedy" client across 10 requests. This prevents a not
125
+ # well behaved client from monopolizing the thread forever.
126
+ MAX_FAST_INLINE = 10
127
+
121
128
  # The original URI requested by the client.
122
129
  REQUEST_URI= 'REQUEST_URI'.freeze
123
130
  REQUEST_PATH = 'REQUEST_PATH'.freeze
@@ -221,6 +228,7 @@ module Puma
221
228
  COLON = ": ".freeze
222
229
 
223
230
  NEWLINE = "\n".freeze
231
+ HTTP_INJECTION_REGEX = /[\r\n]/.freeze
224
232
 
225
233
  HIJACK_P = "rack.hijack?".freeze
226
234
  HIJACK = "rack.hijack".freeze
File without changes
data/lib/puma/detect.rb CHANGED
File without changes
data/lib/puma/dsl.rb CHANGED
File without changes
data/lib/puma/events.rb CHANGED
File without changes
File without changes
File without changes
data/lib/puma/launcher.rb CHANGED
File without changes
File without changes
data/lib/puma/minissl.rb CHANGED
File without changes
data/lib/puma/null_io.rb CHANGED
File without changes
File without changes
data/lib/puma/plugin.rb CHANGED
File without changes
File without changes
File without changes
File without changes
data/lib/puma/reactor.rb CHANGED
File without changes
data/lib/puma/runner.rb CHANGED
File without changes
data/lib/puma/server.rb CHANGED
@@ -466,6 +466,8 @@ module Puma
466
466
  clean_thread_locals = @options[:clean_thread_locals]
467
467
  close_socket = true
468
468
 
469
+ requests = 0
470
+
469
471
  while true
470
472
  case handle_request(client, buffer)
471
473
  when false
@@ -479,7 +481,24 @@ module Puma
479
481
 
480
482
  ThreadPool.clean_thread_locals if clean_thread_locals
481
483
 
482
- unless client.reset(@status == :run)
484
+ requests += 1
485
+
486
+ # Closing keepalive sockets after they've made a reasonable
487
+ # number of requests allows Puma to service many connections
488
+ # fairly, even when the number of concurrent connections exceeds
489
+ # the size of the threadpool. It also allows cluster mode Pumas
490
+ # to keep load evenly distributed across workers, because clients
491
+ # are randomly assigned a new worker when opening a new connection.
492
+ #
493
+ # Previously, Puma would kick connections in this conditional back
494
+ # to the reactor. However, because this causes the todo set to increase
495
+ # in size, the wait_until_full mutex would never unlock, leaving
496
+ # any additional connections unserviced.
497
+ break if requests >= MAX_FAST_INLINE
498
+
499
+ check_for_more_data = @status == :run
500
+
501
+ unless client.reset(check_for_more_data)
483
502
  close_socket = false
484
503
  client.set_timeout @persistent_timeout
485
504
  @reactor.add client
@@ -643,6 +662,7 @@ module Puma
643
662
  headers.each_pair do |k, vs|
644
663
  if vs.respond_to?(:to_s) && !vs.to_s.empty?
645
664
  vs.to_s.split(NEWLINE).each do |v|
665
+ next if possible_header_injection?(v)
646
666
  fast_write client, "#{k}: #{v}\r\n"
647
667
  end
648
668
  else
@@ -657,6 +677,37 @@ module Puma
657
677
  }
658
678
  end
659
679
 
680
+ # Fixup any headers with , in the name to have _ now. We emit
681
+ # headers with , in them during the parse phase to avoid ambiguity
682
+ # with the - to _ conversion for critical headers. But here for
683
+ # compatibility, we'll convert them back. This code is written to
684
+ # avoid allocation in the common case (ie there are no headers
685
+ # with , in their names), that's why it has the extra conditionals.
686
+
687
+ to_delete = nil
688
+ to_add = nil
689
+
690
+ env.each do |k,v|
691
+ if k.start_with?("HTTP_") and k.include?(",") and k != "HTTP_TRANSFER,ENCODING"
692
+ if to_delete
693
+ to_delete << k
694
+ else
695
+ to_delete = [k]
696
+ end
697
+
698
+ unless to_add
699
+ to_add = {}
700
+ end
701
+
702
+ to_add[k.tr(",", "_")] = v
703
+ end
704
+ end
705
+
706
+ if to_delete
707
+ to_delete.each { |k| env.delete(k) }
708
+ env.merge! to_add
709
+ end
710
+
660
711
  # A rack extension. If the app writes #call'ables to this
661
712
  # array, we will invoke them when the request is done.
662
713
  #
@@ -744,6 +795,7 @@ module Puma
744
795
  headers.each do |k, vs|
745
796
  case k.downcase
746
797
  when CONTENT_LENGTH2
798
+ next if possible_header_injection?(vs)
747
799
  content_length = vs
748
800
  next
749
801
  when TRANSFER_ENCODING
@@ -756,6 +808,7 @@ module Puma
756
808
 
757
809
  if vs.respond_to?(:to_s) && !vs.to_s.empty?
758
810
  vs.to_s.split(NEWLINE).each do |v|
811
+ next if possible_header_injection?(v)
759
812
  lines.append k, colon, v, line_ending
760
813
  end
761
814
  else
@@ -820,11 +873,14 @@ module Puma
820
873
  end
821
874
 
822
875
  ensure
823
- uncork_socket client
876
+ begin
877
+ uncork_socket client
824
878
 
825
- body.close
826
- req.tempfile.unlink if req.tempfile
827
- res_body.close if res_body.respond_to? :close
879
+ body.close
880
+ req.tempfile.unlink if req.tempfile
881
+ ensure
882
+ res_body.close if res_body.respond_to? :close
883
+ end
828
884
 
829
885
  after_reply.each { |o| o.call }
830
886
  end
@@ -1026,5 +1082,10 @@ module Puma
1026
1082
  def shutting_down?
1027
1083
  @status == :stop || @status == :restart
1028
1084
  end
1085
+
1086
+ def possible_header_injection?(header_value)
1087
+ HTTP_INJECTION_REGEX =~ header_value.to_s
1088
+ end
1089
+ private :possible_header_injection?
1029
1090
  end
1030
1091
  end
data/lib/puma/single.rb CHANGED
File without changes
File without changes
File without changes
File without changes
data/lib/puma/util.rb CHANGED
File without changes
data/lib/puma.rb CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/tools/trickletest.rb CHANGED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 4.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Phoenix
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-07 00:00:00.000000000 Z
11
+ date: 1980-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nio4r
@@ -121,7 +121,7 @@ licenses:
121
121
  metadata:
122
122
  msys2_mingw_dependencies: openssl
123
123
  changelog_uri: https://github.com/puma/puma/blob/master/History.md
124
- post_install_message:
124
+ post_install_message:
125
125
  rdoc_options: []
126
126
  require_paths:
127
127
  - lib
@@ -136,8 +136,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  requirements: []
139
- rubygems_version: 3.0.3
140
- signing_key:
139
+ rubygems_version: 3.2.26
140
+ signing_key:
141
141
  specification_version: 4
142
142
  summary: Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for
143
143
  Ruby/Rack applications