Alexis La Goutte
1241c951d6
rv is only used in an assert.
...
The assert only evaluates to code if NDEBUG is undefined. Protect rv and its use accordingly
Issue reported by Joerg Mayer
https://code.wireshark.org/review/8260
2015-05-07 15:20:24 +02:00
Tatsuhiro Tsujikawa
fc17c0a618
Fix global-buffer-overflow
2015-05-07 19:37:43 +09:00
Tatsuhiro Tsujikawa
02468b1ca1
Allocate field name and value in the same buffer if indname to dynamic table
2015-04-26 18:43:24 +09:00
Tatsuhiro Tsujikawa
58b7f4a096
Fix inline error with travis gcc-4.8
2015-04-22 23:59:23 +09:00
Tatsuhiro Tsujikawa
91ad7e150e
Never indexing still can use header field name in dynamic table
2015-04-19 18:21:26 +09:00
Tatsuhiro Tsujikawa
a3fa257473
Fix compile error with Android NDK r10d + --enable-werror
2015-04-17 23:46:19 +09:00
Tatsuhiro Tsujikawa
93afbc7d2f
Rewrite static header table handling
...
We rewrite static header table handling in nghttp2_hd.c. We expand
nghttp2_token to include all static header table entries, and fully
use them in header compression and decompression. The lookup function
is now located in nghttp2_hd.c. We add new nghttp2_hd_inflate_hd2()
function to export token value for header name, then we pass it to
nghttp2_http_on_header function, so that we don't have to look up
token there. We carefully set enum value of token to static table
index, so looking up static table is now O(1), assuming we have token.
2015-04-15 23:58:56 +09:00
Tatsuhiro Tsujikawa
82e2c5bd22
Never index authorization and small cookie header field
...
nghttp2 library now use Literal Header Field never Indexed for
"authorization" header field and small "cookie" header field,
regardless of nghttp2_nv.flags.
2015-04-15 23:58:56 +09:00
Tatsuhiro Tsujikawa
d3d6c5e314
Fix bug that inflater->nvbufs is not reset
2015-03-24 21:54:05 +09:00
Tatsuhiro Tsujikawa
661fb2eb0e
NULL-terminate name and value in nghttp2_nv
...
Guaranteeing NULL-termination is very useful when name or value are
used with C functions which requires NULL-terminated string.
2015-03-23 23:25:57 +09:00
Tatsuhiro Tsujikawa
4430b06c71
Add parentheses around macro parameters
2015-02-22 17:43:14 +09:00
Tatsuhiro Tsujikawa
ce1bf11d4b
Fix memory leak
2014-12-18 21:02:44 +09:00
Tatsuhiro Tsujikawa
c0ffed7788
Support custom memory allocator
...
nghttp2_mem structure is introduced to hold custom memory allocator
functions and user supplied pointer. nghttp2_mem object can be passed
to nghttp2_session_client_new3(), nghttp2_session_server_new3(),
nghttp2_hd_deflate_new2() and nghttp2_hd_inflate_new2() to replace
standard malloc(), free(), calloc() and realloc(). nghttp2_mem
structure has user supplied pointer mem_user_data which can be used as
per session/object memory pool.
2014-12-08 00:55:55 +09:00
Tatsuhiro Tsujikawa
b1f807abd1
Reformat lines with clang-format-3.5
2014-11-27 23:56:30 +09:00
Alexis La Goutte
bac44d7ffb
Fix -Werror=unused-parameter using _U_ macro
2014-11-25 17:08:09 +01:00
Tatsuhiro Tsujikawa
4ee89e62fc
nghttp2_hd: Refactor a bit
2014-11-21 01:59:20 +09:00
Tatsuhiro Tsujikawa
7d282cd0bd
Code cleanup
2014-10-30 23:31:28 +09:00
Tatsuhiro Tsujikawa
b3463b20a3
Update doc
2014-10-27 21:24:41 +09:00
Tatsuhiro Tsujikawa
7e6019aef1
nghttp2_hd: Don't malloc if name/value is in first chunk without indexing
2014-09-30 23:01:58 +09:00
Tatsuhiro Tsujikawa
a82956d1d6
nghttp2_hd: Use binary search to lookup static table (again)
2014-09-29 21:58:37 +09:00
Tatsuhiro Tsujikawa
b48ceac56c
nghttp2_hd: Search dynamic table first
...
Since recently used headers are in dynamic header table, it is
advantageous to search dynamic table first, saving time to search
through static table.
2014-09-27 23:45:58 +09:00
Tatsuhiro Tsujikawa
6ccf06c6da
nghtp2_hd: Calculate hash values once
2014-08-06 22:00:12 +09:00
Tatsuhiro Tsujikawa
49e3fd6862
Add some header names which won't be indexed
2014-08-06 21:50:54 +09:00
Alexis La Goutte
ec93c9f55f
Fix some other shorten-64-to-32 casting error found by MSVC (64bits)
...
Thanks to Pascal
2014-08-04 09:04:49 +02:00
Alexis La Goutte
6c71889552
Fix some other shorten-64-to-32 casting error found by MSVC (64bits)
2014-08-03 16:09:30 +02:00
Tatsuhiro Tsujikawa
4bbb4172aa
Fix typo
2014-08-03 14:07:35 +09:00
Tatsuhiro Tsujikawa
3c603ec4ae
add_hd_table_incremental: Remove unused bufs parameter
2014-08-02 16:21:42 +09:00
Tatsuhiro Tsujikawa
d36bea8554
Add debug output for HPACK decoded integer
2014-08-02 10:40:25 +09:00
Tatsuhiro Tsujikawa
d8d14a3fc9
Code cleanup
2014-07-31 23:08:51 +09:00
Tatsuhiro Tsujikawa
c4be7d48a0
nghttp2_hd: Code cleanup
2014-07-31 23:05:53 +09:00
Tatsuhiro Tsujikawa
0752ce6701
nghttp2_hd_deflate_bound: Take into account possible 2nd context update
2014-07-31 23:05:53 +09:00
Tatsuhiro Tsujikawa
dd1850aed0
Emit minimum header table size in encoding context update
2014-07-31 23:05:53 +09:00
Tatsuhiro Tsujikawa
e147c14186
Remove ent_name member and use index solely
2014-07-31 23:05:52 +09:00
Tatsuhiro Tsujikawa
06453fb15e
Remove unused role member in nghttp2_hd_context
2014-07-31 23:05:52 +09:00
Tatsuhiro Tsujikawa
744ec4dba1
Don't copy static header and put static table in front of dynamic table
2014-07-31 23:05:52 +09:00
Tatsuhiro Tsujikawa
38bfbffb1b
Remove HPACK reference set
2014-07-31 23:05:52 +09:00
Tatsuhiro Tsujikawa
961dcf614a
Fix wrong detection of neverIndex bit
2014-07-26 23:27:34 +09:00
Tatsuhiro Tsujikawa
57e9b94aaa
Handle header table size up to UINT32_MAX
2014-07-22 22:38:18 +09:00
Tatsuhiro Tsujikawa
9de9b6ebd6
Remove unnecessarily code
2014-07-22 01:52:51 +09:00
Tatsuhiro Tsujikawa
44310c6de5
Fix integer decoding when it takes multiple reads
2014-07-22 01:50:29 +09:00
Tatsuhiro Tsujikawa
d99e1135c8
Search static header table linearly
2014-07-20 19:13:56 +09:00
Tatsuhiro Tsujikawa
67b13ad9ff
Remove unused nghttp2_nva_out
2014-07-18 21:14:07 +09:00
Tatsuhiro Tsujikawa
8dc47c6750
Fix resource leaks
2014-07-18 00:31:32 +09:00
Tatsuhiro Tsujikawa
62423f5949
Fix double free
2014-07-15 22:47:04 +09:00
Tatsuhiro Tsujikawa
bd06f2cec3
Add const qualifier to nva parameter in nghttp2_hd_deflate_hd()
2014-06-29 23:43:14 +09:00
Tatsuhiro Tsujikawa
d318e6a62e
Support one header field size (name + value) up to 64KiB by default
...
This commits changes the upper bound of one header field size (the sum
of the length of name and value) to 64KiB by default. We may add an
option to change this upper bound in the future.
2014-06-28 11:04:41 +09:00
Tatsuhiro Tsujikawa
16fef227e8
nghttp2_hd_*_new: Leave *inflater_ptr or *deflater_ptr untouched on failure
2014-06-25 21:26:47 +09:00
Tatsuhiro Tsujikawa
31de732e3b
Allocate header table ringbuffer lazily
...
Previously in inflater we reserve new ringbuffer when table size is
changed. This may be potentially a problem if new table size is very
large number. When inflater is not used directly by application, this
is not a problem because application can choose the buffer size. On
the other hand, if application uses inflater directly and it does not
have control of new buffer size (e.g., protocol dissector), then we
just fail to allocate large buffer in
nghttp2_hd_inflate_change_table_size() without actually use such huge
buffer. This change defers the actual allocation of buffer when it is
actually needed so that we will fail when it is absolutely needed.
2014-06-22 13:39:17 +09:00
Alexis La Goutte
9a3cdeb7e6
Fix some other shorten-64-to-32 casting error found by MSVC (64bits)
...
Thanks for Pascal
2014-06-16 19:17:49 +02:00
Alexis La Goutte
c9b6371977
When assertions is disable, there is a warning about unused check_index_range function
...
Make the check for a valid index range a macro, so the compiler doesn't
whine if it's not used, but it's available if it *is* used.
2014-06-16 18:52:11 +02:00
Tatsuhiro Tsujikawa
f85a213fb1
Update static header table
2014-06-14 22:24:47 +09:00
Tatsuhiro Tsujikawa
9b174bf5c9
Fix compile error with -Wshorten-64-to-32
...
The original patch was contributed by Alexis La Goutte
2014-06-11 23:37:16 +09:00
Alexis La Goutte
6b08534ffc
Fix declaration of ‘index’ shadows a global declaration [-Werror=shadow]
...
I have this error with some old gcc (4.6) release (Ubuntu 12.04 or Travis...)
2014-06-03 10:20:05 +02:00
Tatsuhiro Tsujikawa
d113055899
nghttp2_hd: Use single buffer for an name/value pair
...
Previously we use 2 separate buffer for each name and value. The
problem is we would waste buffer space for name because it is usually
small. Also tuning buffer size for each buffer separately is not
elegant and current HTTP server practice is that one buffer for 1
name/value pair. This commit unifies 2 buffers into 1.
2014-05-28 23:33:37 +09:00
Tatsuhiro Tsujikawa
7b9a8acc22
Add HPACK deflation API
2014-05-13 23:42:55 +09:00
Tatsuhiro Tsujikawa
ab76468971
Return NGHTTP2_ERR_BUFFER_ERROR from nghttp2_hd_{deflate,inflate}_hd
...
It is generally useful to know what is the cause of the error. Since
we expose HPACK API, it is friendly to tell application the
insufficient buffer size is a culprit.
2014-05-12 22:58:04 +09:00
Tatsuhiro Tsujikawa
2e5c7f598f
Fix bug HPACK deflater does not send context update after table size change
2014-05-11 21:25:27 +09:00
Tatsuhiro Tsujikawa
3ebb3faf32
Remove nghttp2_ prefix from static function, part 2
2014-05-08 23:54:07 +09:00
Tatsuhiro Tsujikawa
855f39743a
Fix crash when indexed repr index=0
2014-05-01 09:06:54 +09:00
Tatsuhiro Tsujikawa
660c536275
Extend namelen and valuelen in nghttp2_nv to size_t
2014-04-30 23:08:34 +09:00
Tatsuhiro Tsujikawa
1b79114d2d
Fix compiler warnings
2014-04-30 22:16:21 +09:00
Tatsuhiro Tsujikawa
d2e64317ba
Code cleanup, include nghttp2_int.h explicitly to ensure debug macro
2014-04-30 22:08:32 +09:00
Alexis La Goutte
e00b8f1f73
Fix Dead Store (Dead assignement/Dead increment) warning found by Clang Analyzer
2014-04-30 22:06:42 +09:00
Tatsuhiro Tsujikawa
fe6b541233
Handle hd inflate buffer allocation failure
2014-04-30 11:32:05 +09:00
Tatsuhiro Tsujikawa
3b4aedd566
Add HPACK decoder public API
2014-04-29 15:53:46 +09:00
Tatsuhiro Tsujikawa
b1722cbe28
Update static table
2014-04-02 01:30:50 +09:00
Tatsuhiro Tsujikawa
7877b676e3
Honor NGHTTP2_NV_FLAG_NO_INDEX in deflater and inflater
2014-04-02 01:25:44 +09:00
Tatsuhiro Tsujikawa
24cb90806d
Add flags to nghttp2_nv structure
...
This is preliminary change for upcoming HPACK updates. The flags are
used to determine the name/value pair is indexable or not.
2014-04-01 23:17:50 +09:00
Tatsuhiro Tsujikawa
ab2dc5967d
Replace HTTP/2.0 with HTTP/2
2014-03-30 19:26:37 +09:00
Tatsuhiro Tsujikawa
d0fbbe6932
Less cryptic debug message
2014-03-20 00:27:39 +09:00
Tatsuhiro Tsujikawa
142b433533
nghttp2_hd: Treat prematurely ended compressed header block as error properly
2014-03-14 00:52:44 +09:00
Tatsuhiro Tsujikawa
344d663e90
deflate_hd: Fix mishandled error return from emit_indexed_block
2014-03-14 00:25:03 +09:00
Tatsuhiro Tsujikawa
d07bb1ddff
Rework outbound frame buffers
2014-03-13 22:11:02 +09:00
Tatsuhiro Tsujikawa
3f56c938d8
nghttp2_hd: Use nghttp2_bufs, avoiding realloc()
2014-03-11 21:18:28 +09:00
Tatsuhiro Tsujikawa
358b4386d3
Introduce nghttp2_buf to ease buffer management
2014-03-11 01:47:38 +09:00
Tatsuhiro Tsujikawa
79c5032708
nghttp2_hd: Fix crash with multiple threads execution
2014-03-03 00:53:04 +09:00
Tatsuhiro Tsujikawa
1fee4fd2df
nghttp2_hd: Fail inflate immediately if ctx.bad is nonzero
...
Doing inflation after error produces invalid results, especially, if
it is in NGHTTP2_HD_STATE_READ_INDEX, the inflater->left could be 0,
which causes assertion error. Add sanity assertion for index
2014-02-26 23:20:52 +09:00
Tatsuhiro Tsujikawa
18357512ed
nghttp2_hd: Fix integer decoding bug
2014-02-26 21:44:48 +09:00
Tatsuhiro Tsujikawa
fd88c6160d
HPACK post -05 updates
...
* Use 1 Huffman code table for both request and response
* Remove complicated deflater side table size management
* Add encoding context update
* Fix memory leak in inflater
2014-02-13 23:22:52 +09:00
Tatsuhiro Tsujikawa
cacf4ecf26
Fix premature header block is not treated as connection error
2014-02-11 16:00:59 +09:00
Tatsuhiro Tsujikawa
9314e30987
Support transmission of CONTINUATION, change nghttp2_frame_hd
...
The maximum frame size including header block is still limited
to NGHTTP2_HD_MAX_BUFFER_LENGTH, which is 32KB.
2014-01-26 23:10:33 +09:00
Tatsuhiro Tsujikawa
e7fc2951b8
nghttp2_hd: Define dedicated struct for HPACK deflater and inflater
2014-01-26 17:53:04 +09:00
Tatsuhiro Tsujikawa
8317559090
nghttp2_hd: Implement stream header inflater
...
This stream inflater can inflate incoming header block in streaming
fashion. Currently, we buffer up single name/value pair, but we chose
far more smaller buffer size than HTTP/2 frame size.
2014-01-25 18:24:15 +09:00
Tatsuhiro Tsujikawa
201ab1a140
nghttp2_hd: Adjust maximum size to index based on table size
2014-01-21 21:49:53 +09:00
Tatsuhiro Tsujikawa
073e6d3a01
nghttp2_hd: Remove unused variables
2014-01-17 09:36:38 +09:00
Tatsuhiro Tsujikawa
0e4b3d435e
Emit header name/value pair using callback functions
...
Now, in nghttp2_on_frame_recv_callback, nva and nvlen in
HEADERS and PUSH_PROMISE frames are always NULL and 0 respectively.
The header name/value pairs are emitted successive
nghttp2_on_header_callback functions. The end of header fields are
signaled with nghttp2_on_end_headers_callback function.
Since NGHTTP2_ERR_PAUSE for nghttp2_on_frame_recv_callback is
introduced to handle header block, it is now deprecated.
Instead, nghttp2_on_header_callback can be paused using
NGHTTP2_ERR_PAUSE.
2014-01-17 01:49:43 +09:00
Tatsuhiro Tsujikawa
63e7b21b35
nghttp2_hd: Fix lower bound search in static table
2014-01-08 21:32:39 +09:00
Tatsuhiro Tsujikawa
0fb4d32d6a
nghttp2_hd: Binary search static table
2014-01-07 23:41:09 +09:00
Tatsuhiro Tsujikawa
468d0fccd3
nghttp2_hd: Use hash to speed up name/value pair search
2014-01-07 22:43:34 +09:00
Tatsuhiro Tsujikawa
d703197a50
nghttp2_hd: Mitigate timing attack
2014-01-07 21:51:48 +09:00
Tatsuhiro Tsujikawa
9eb031ce83
nghttp2_hd: Avoid nghttp2_hd_huff_decode_count
...
Huffman decoding is costly. It is faster to do geometric realloc
than calling nghttp2_hd_huff_decode_count to know the length in
advance.
2014-01-07 21:44:56 +09:00
Tatsuhiro Tsujikawa
4ac1652c70
nghttp2_hd: Remove invalid nghttp2_downcase call
2014-01-07 21:18:45 +09:00
Tatsuhiro Tsujikawa
dfcdea894b
Move header name/value pair validation to on_*_received functions
2013-12-25 23:38:55 +09:00
Tatsuhiro Tsujikawa
7c4dbb6ffc
nghttp2_hd: Don't malloc if huffman encoded string has 0 length
2013-12-19 23:19:14 +09:00
Tatsuhiro Tsujikawa
5ca0cfa018
nghttp2_hd: Search hd table once
2013-12-18 21:45:15 +09:00
Tatsuhiro Tsujikawa
01266182e9
nghttp2_hd: Match deflate_hd_tablelen to hd_table.len on decoder side
2013-12-17 21:39:21 +09:00
Tatsuhiro Tsujikawa
595493a0ec
Add debug output in nghttp2_hd
2013-12-16 23:54:20 +09:00
Tatsuhiro Tsujikawa
e61876ccbd
nghttp2_hd: Provide dedicated function to enable no reference set feature
2013-12-14 18:48:41 +09:00
Tatsuhiro Tsujikawa
e5e4fc9d14
nghttp2_hd: Define some headers not for indexing based on our research
2013-11-19 21:41:02 +09:00
Tatsuhiro Tsujikawa
8915e91b17
nghttp2_hd: Enlarge buffers used in inflation process dynamically
2013-11-16 23:13:46 +09:00