Skip to content

Commit 895c71e

Browse files
author
MarcoFalke
committed
Merge #18682: fuzz: http_request workaround for libevent < 2.1.1
6f8b498 fuzz: http_request workaround for libevent < 2.1.1 (Sebastian Falbesoner) Pull request description: The fuzz test `http_request` calls the following two internal libevent functions: * `evhttp_parse_firstline_` * `evhttp_parse_headers_` Before libevent 2.1.1 however, internal functions names didn't end with an underscore (see libevent commit libevent/libevent@8ac3c4c and [Changelog for 2.1.1.-alpha](https://github.com/libevent/libevent/blob/master/ChangeLog#L1830) when the change was first mentioned) hence the build fails with a linking error. This PR adds a preprocessor workaround to the test that checks for the libevent version (via ~`_EVENT_NUMERIC_VERSION`~ `LIBEVENT_VERSION_NUMBER`) and creates wrapper functions mapping to naming scheme without underscore in case the version is older than 2.1.1. Tested with Ubuntu Xenial 16.04.6 LTS and clang-8. ACKs for top commit: hebasto: ACK 6f8b498, tested on xenial: Tree-SHA512: 3b9e0147b8aea22e417d418e3b6d4905f5be131c2b0ae4b0f8b9411c5606d2e22f1b23e1ecc6980ecab907c61404de09e588aae1ac43cf70cf9e8d006bbdee73
2 parents c54295c + 6f8b498 commit 895c71e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/test/fuzz/http_request.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <test/fuzz/util.h>
1010

1111
#include <event2/buffer.h>
12+
#include <event2/event.h>
1213
#include <event2/http.h>
1314
#include <event2/http_struct.h>
1415

@@ -17,8 +18,24 @@
1718
#include <string>
1819
#include <vector>
1920

21+
// workaround for libevent versions before 2.1.1,
22+
// when internal functions didn't have underscores at the end
23+
#if LIBEVENT_VERSION_NUMBER < 0x02010100
24+
extern "C" int evhttp_parse_firstline(struct evhttp_request*, struct evbuffer*);
25+
extern "C" int evhttp_parse_headers(struct evhttp_request*, struct evbuffer*);
26+
inline int evhttp_parse_firstline_(struct evhttp_request* r, struct evbuffer* b)
27+
{
28+
return evhttp_parse_firstline(r, b);
29+
}
30+
inline int evhttp_parse_headers_(struct evhttp_request* r, struct evbuffer* b)
31+
{
32+
return evhttp_parse_headers(r, b);
33+
}
34+
#else
2035
extern "C" int evhttp_parse_firstline_(struct evhttp_request*, struct evbuffer*);
2136
extern "C" int evhttp_parse_headers_(struct evhttp_request*, struct evbuffer*);
37+
#endif
38+
2239
std::string RequestMethodString(HTTPRequest::RequestMethod m);
2340

2441
void test_one_input(const std::vector<uint8_t>& buffer)

0 commit comments

Comments
 (0)