mirror of
https://github.com/nghttp2/nghttp2.git
synced 2025-12-06 18:18:52 +08:00
This commit deprecates all APIs, including structs and callback functions, that use ssize_t. New APIs that use nghttp2_ssize are added as a replacement. The usage of ssize_t is problematic for several reasons. Some platforms do not define ssize_t. The minimum value of ssize_t that POSIX requires is -1 which makes nghttp2 error code out of range. nghttp2_ssize is an alias of ptrdiff_t that is in C standard and covers our error code range. New code should use new nghttp2_ssize APIs. The existing applications should consider migrating to new APIs. The deprecated ssize_t APIs continue to work for backward compatibility. Here is the summary of the deprecated APIs and their replacements: Callback functions: - nghttp2_data_source_read_callback => nghttp2_data_source_read_callback2 - nghttp2_data_source_read_length_callback => nghttp2_data_source_read_length_callback2 - nghttp2_pack_extension_callback => nghttp2_pack_extension_callback2 - nghttp2_recv_callback => nghttp2_recv_callback2 - nghttp2_select_padding_callback => nghttp2_select_padding_callback2 - nghttp2_send_callback => nghttp2_send_callback2 Structs: - nghttp2_data_provider => nghttp2_data_provider2 Functions: - nghttp2_hd_deflate_hd => nghttp2_hd_deflate_hd2 - nghttp2_hd_deflate_hd_vec => nghttp2_hd_deflate_hd_vec2 - nghttp2_hd_inflate_hd2 => nghttp2_hd_inflate_hd3 - nghttp2_pack_settings_payload => nghttp2_pack_settings_payload2 - nghttp2_session_callbacks_set_data_source_read_length_callback => nghttp2_session_callbacks_set_data_source_read_length_callback2 - nghttp2_session_callbacks_set_pack_extension_callback => nghttp2_session_callbacks_set_pack_extension_callback2 - nghttp2_session_callbacks_set_recv_callback => nghttp2_session_callbacks_set_recv_callback2 - nghttp2_session_callbacks_set_select_padding_callback => nghttp2_session_callbacks_set_select_padding_callback2 - nghttp2_session_callbacks_set_send_callback => nghttp2_session_callbacks_set_send_callback2 - nghttp2_session_mem_recv => nghttp2_session_mem_recv2 - nghttp2_session_mem_send => nghttp2_session_mem_send2 - nghttp2_submit_data => nghttp2_submit_data2 - nghttp2_submit_request => nghttp2_submit_request2 - nghttp2_submit_response => nghttp2_submit_response2 For those applications that do not want to see ssize_t in nghttp2.h header file, define NGHTTP2_NO_SSIZE_T macro before including nghttp2.h. It hides all ssize_t APIs.
Fuzzer
======
This directory contains fuzzer target mainly written to integrate
nghttp2 into `oss-fuzz <https://github.com/google/oss-fuzz>`_.
fuzz_target.cc contains an entry point of fuzzer. corpus directory
contains initial data for fuzzer.
The file name of initial data under corpus is the lower-cased hex
string of SHA-256 hash of its own content.
corpus/h2spec contains input data which was recorded when we ran
`h2spec <https://github.com/summerwind/h2spec>`_ against nghttpd.
corpus/nghttp contains input data which was recorded when we ran
nghttp against nghttpd with some varying command line options of
nghttp.
To build fuzz_target.cc, make sure that libnghttp2 is built with
following compiler/linker flags:
.. code-block:: text
CPPFLAGS="-fsanitize-coverage=edge -fsanitize=address"
LDFLAGS="-fsanitize-coverage=edge -fsanitize=address"
Then, fuzz_target.cc can be built using the following command:
.. code-block:: text
$ clang++ -fsanitize-coverage=edge -fsanitize=address -I../lib/includes -std=c++11 fuzz_target.cc ../lib/.libs/libnghttp2.a /usr/lib/llvm-3.9/lib/libFuzzer.a -o nghttp2_fuzzer