Skip to content

Commit 6b8d02a

Browse files
committed
http: fix undefined-shift in EVUTIL_IS*_ helpers
evutil.c:2559:1: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' #0 0x4f2be0 in EVUTIL_ISXDIGIT_ libevent/evutil.c:2559:1 #1 0x4bd689 in regname_ok libevent/http.c:4838:7 #2 0x4bc16b in parse_authority libevent/http.c:4958:9 #3 0x4bb8b5 in evhttp_uri_parse_with_flags libevent/http.c:5103:7 #4 0x4bb762 in evhttp_uri_parse libevent/http.c:5050:9 libevent#5 0x4b8f41 in evhttp_parse_query_impl libevent/http.c:3505:9 libevent#6 0x4b8ed7 in evhttp_parse_query libevent/http.c:3569:9 Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23291 Report: https://oss-fuzz.com/testcase-detail/5670743106125824 (cherry picked from commit 37dbb35)
1 parent 97e28f0 commit 6b8d02a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

evutil.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2369,7 +2369,7 @@ static const unsigned char EVUTIL_TOLOWER_TABLE[256] = {
23692369
#define IMPL_CTYPE_FN(name) \
23702370
int EVUTIL_##name##_(char c) { \
23712371
ev_uint8_t u = c; \
2372-
return !!(EVUTIL_##name##_TABLE[(u >> 5) & 7] & (1 << (u & 31))); \
2372+
return !!(EVUTIL_##name##_TABLE[(u >> 5) & 7] & (1U << (u & 31))); \
23732373
}
23742374
IMPL_CTYPE_FN(ISALPHA)
23752375
IMPL_CTYPE_FN(ISALNUM)

test/regress_util.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,16 @@ test_evutil_rand(void *arg)
984984
;
985985
}
986986

987+
static void
988+
test_EVUTIL_IS_(void *arg)
989+
{
990+
tt_int_op(EVUTIL_ISDIGIT_('0'), ==, 1);
991+
tt_int_op(EVUTIL_ISDIGIT_('a'), ==, 0);
992+
tt_int_op(EVUTIL_ISDIGIT_('\xff'), ==, 0);
993+
end:
994+
;
995+
}
996+
987997
static void
988998
test_evutil_getaddrinfo(void *arg)
989999
{
@@ -1611,6 +1621,7 @@ struct testcase_t util_testcases[] = {
16111621
{ "upcast", test_evutil_upcast, 0, NULL, NULL },
16121622
{ "integers", test_evutil_integers, 0, NULL, NULL },
16131623
{ "rand", test_evutil_rand, TT_FORK, NULL, NULL },
1624+
{ "EVUTIL_IS_", test_EVUTIL_IS_, 0, NULL, NULL },
16141625
{ "getaddrinfo", test_evutil_getaddrinfo, TT_FORK, NULL, NULL },
16151626
{ "getaddrinfo_live", test_evutil_getaddrinfo_live, TT_FORK|TT_OFF_BY_DEFAULT, NULL, NULL },
16161627
#ifdef _WIN32

0 commit comments

Comments
 (0)