| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 33d4d91 commit 6d42737
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2648,6 +2648,17 @@ nghttp2_option_set_max_deflate_dynamic_table_size(nghttp2_option *option, | |||
| 2648 | 2648 | NGHTTP2_EXTERN void nghttp2_option_set_no_closed_streams(nghttp2_option *option, | |
| 2649 | 2649 | int val); | |
| 2650 | 2650 | ||
| 2651 | + /** | ||
| 2652 | + * @function | ||
| 2653 | + * | ||
| 2654 | + * This function sets the maximum number of outgoing SETTINGS ACK and | ||
| 2655 | + * PING ACK frames retained in :type:`nghttp2_session` object. If | ||
| 2656 | + * more than those frames are retained, the peer is considered to be | ||
| 2657 | + * misbehaving and session will be closed. The default value is 1000. | ||
| 2658 | + */ | ||
| 2659 | + NGHTTP2_EXTERN void nghttp2_option_set_max_outbound_ack(nghttp2_option *option, | ||
| 2660 | + size_t val); | ||
| 2661 | + | ||
| 2651 | 2662 | /** | |
| 2652 | 2663 | * @function | |
| 2653 | 2664 | * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,14 +29,14 @@ | |||
| 29 | 29 | * @macro | |
| 30 | 30 | * Version number of the nghttp2 library release | |
| 31 | 31 | */ | |
| 32 | - #define NGHTTP2_VERSION "1.39.1" | ||
| 32 | + #define NGHTTP2_VERSION "1.39.2" | ||
| 33 | 33 | ||
| 34 | 34 | /** | |
| 35 | 35 | * @macro | |
| 36 | 36 | * Numerical representation of the version number of the nghttp2 library | |
| 37 | 37 | * release. This is a 24 bit number with 8 bits for major number, 8 bits | |
| 38 | 38 | * for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203. | |
| 39 | 39 | */ | |
| 40 | - #define NGHTTP2_VERSION_NUM 0x012701 | ||
| 40 | + #define NGHTTP2_VERSION_NUM 0x012702 | ||
| 41 | 41 | ||
| 42 | 42 | #endif /* NGHTTP2VER_H */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -116,3 +116,8 @@ void nghttp2_option_set_no_closed_streams(nghttp2_option *option, int val) { | |||
| 116 | 116 | option->opt_set_mask |= NGHTTP2_OPT_NO_CLOSED_STREAMS; | |
| 117 | 117 | option->no_closed_streams = val; | |
| 118 | 118 | } | |
| 119 | + | ||
| 120 | + void nghttp2_option_set_max_outbound_ack(nghttp2_option *option, size_t val) { | ||
| 121 | + option->opt_set_mask |= NGHTTP2_OPT_MAX_OUTBOUND_ACK; | ||
| 122 | + option->max_outbound_ack = val; | ||
| 123 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -66,6 +66,7 @@ typedef enum { | |||
| 66 | 66 | NGHTTP2_OPT_MAX_SEND_HEADER_BLOCK_LENGTH = 1 << 8, | |
| 67 | 67 | NGHTTP2_OPT_MAX_DEFLATE_DYNAMIC_TABLE_SIZE = 1 << 9, | |
| 68 | 68 | NGHTTP2_OPT_NO_CLOSED_STREAMS = 1 << 10, | |
| 69 | + NGHTTP2_OPT_MAX_OUTBOUND_ACK = 1 << 11, | ||
| 69 | 70 | } nghttp2_option_flag; | |
| 70 | 71 | ||
| 71 | 72 | /** | |
@@ -80,6 +81,10 @@ struct nghttp2_option { | |||
| 80 | 81 | * NGHTTP2_OPT_MAX_DEFLATE_DYNAMIC_TABLE_SIZE | |
| 81 | 82 | */ | |
| 82 | 83 | size_t max_deflate_dynamic_table_size; | |
| 84 | + /** | ||
| 85 | + * NGHTTP2_OPT_MAX_OUTBOUND_ACK | ||
| 86 | + */ | ||
| 87 | + size_t max_outbound_ack; | ||
| 83 | 88 | /** | |
| 84 | 89 | * Bitwise OR of nghttp2_option_flag to determine that which fields | |
| 85 | 90 | * are specified. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -457,6 +457,7 @@ static int session_new(nghttp2_session **session_ptr, | |||
| 457 | 457 | (*session_ptr)->remote_settings.max_concurrent_streams = 100; | |
| 458 | 458 | ||
| 459 | 459 | (*session_ptr)->max_send_header_block_length = NGHTTP2_MAX_HEADERSLEN; | |
| 460 | + (*session_ptr)->max_outbound_ack = NGHTTP2_DEFAULT_MAX_OBQ_FLOOD_ITEM; | ||
| 460 | 461 | ||
| 461 | 462 | if (option) { | |
| 462 | 463 | if ((option->opt_set_mask & NGHTTP2_OPT_NO_AUTO_WINDOW_UPDATE) && | |
@@ -516,6 +517,10 @@ static int session_new(nghttp2_session **session_ptr, | |||
| 516 | 517 | option->no_closed_streams) { | |
| 517 | 518 | (*session_ptr)->opt_flags |= NGHTTP2_OPTMASK_NO_CLOSED_STREAMS; | |
| 518 | 519 | } | |
| 520 | + | ||
| 521 | + if (option->opt_set_mask & NGHTTP2_OPT_MAX_OUTBOUND_ACK) { | ||
| 522 | + (*session_ptr)->max_outbound_ack = option->max_outbound_ack; | ||
| 523 | + } | ||
| 519 | 524 | } | |
| 520 | 525 | ||
| 521 | 526 | rv = nghttp2_hd_deflate_init2(&(*session_ptr)->hd_deflater, | |
@@ -6857,7 +6862,7 @@ int nghttp2_session_add_ping(nghttp2_session *session, uint8_t flags, | |||
| 6857 | 6862 | mem = &session->mem; | |
| 6858 | 6863 | ||
| 6859 | 6864 | if ((flags & NGHTTP2_FLAG_ACK) && | |
| 6860 | - session->obq_flood_counter_ >= NGHTTP2_MAX_OBQ_FLOOD_ITEM) { | ||
| 6865 | + session->obq_flood_counter_ >= session->max_outbound_ack) { | ||
| 6861 | 6866 | return NGHTTP2_ERR_FLOODED; | |
| 6862 | 6867 | } | |
| 6863 | 6868 | ||
@@ -7002,7 +7007,7 @@ int nghttp2_session_add_settings(nghttp2_session *session, uint8_t flags, | |||
| 7002 | 7007 | return NGHTTP2_ERR_INVALID_ARGUMENT; | |
| 7003 | 7008 | } | |
| 7004 | 7009 | ||
| 7005 | - if (session->obq_flood_counter_ >= NGHTTP2_MAX_OBQ_FLOOD_ITEM) { | ||
| 7010 | + if (session->obq_flood_counter_ >= session->max_outbound_ack) { | ||
| 7006 | 7011 | return NGHTTP2_ERR_FLOODED; | |
| 7007 | 7012 | } | |
| 7008 | 7013 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -97,7 +97,7 @@ typedef struct { | |||
| 97 | 97 | response frames are stacked up, which leads to memory exhaustion. | |
| 98 | 98 | The value selected here is arbitrary, but safe value and if we have | |
| 99 | 99 | these frames in this number, it is considered suspicious. */ | |
| 100 | - #define NGHTTP2_MAX_OBQ_FLOOD_ITEM 10000 | ||
| 100 | + #define NGHTTP2_DEFAULT_MAX_OBQ_FLOOD_ITEM 1000 | ||
| 101 | 101 | ||
| 102 | 102 | /* The default value of maximum number of concurrent streams. */ | |
| 103 | 103 | #define NGHTTP2_DEFAULT_MAX_CONCURRENT_STREAMS 0xffffffffu | |
@@ -258,8 +258,12 @@ struct nghttp2_session { | |||
| 258 | 258 | size_t num_idle_streams; | |
| 259 | 259 | /* The number of bytes allocated for nvbuf */ | |
| 260 | 260 | size_t nvbuflen; | |
| 261 | - /* Counter for detecting flooding in outbound queue */ | ||
| 261 | + /* Counter for detecting flooding in outbound queue. If it exceeds | ||
| 262 | + max_outbound_ack, session will be closed. */ | ||
| 262 | 263 | size_t obq_flood_counter_; | |
| 264 | + /* The maximum number of outgoing SETTINGS ACK and PING ACK in | ||
| 265 | + outbound queue. */ | ||
| 266 | + size_t max_outbound_ack; | ||
| 263 | 267 | /* The maximum length of header block to send. Calculated by the | |
| 264 | 268 | same way as nghttp2_hd_deflate_bound() does. */ | |
| 265 | 269 | size_t max_send_header_block_length; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments