Skip to content

Commit 7e121df

Browse files
authored
Merge pull request #345 from ngtcp2/add-http-tests
Add more HTTP header related tests
2 parents 8d495f6 + 17f5b11 commit 7e121df

File tree

4 files changed

+414
-7
lines changed

4 files changed

+414
-7
lines changed

lib/nghttp3_http.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ static int64_t parse_uint(const uint8_t *s, size_t len) {
6969
}
7070
for (i = 0; i < len; ++i) {
7171
if ('0' <= s[i] && s[i] <= '9') {
72-
if (n > INT64_MAX / 10) {
72+
if (n > (int64_t)NGHTTP3_MAX_VARINT / 10) {
7373
return -1;
7474
}
7575
n *= 10;
76-
if (n > INT64_MAX - (s[i] - '0')) {
76+
if (n > (int64_t)NGHTTP3_MAX_VARINT - (s[i] - '0')) {
7777
return -1;
7878
}
7979
n += s[i] - '0';
@@ -549,6 +549,9 @@ static int http_request_on_header(nghttp3_http_state *http,
549549
break;
550550
case NGHTTP3_QPACK_TOKEN_PRIORITY:
551551
if (!nghttp3_check_header_value(nv->value->base, nv->value->len)) {
552+
http->flags &= ~NGHTTP3_HTTP_FLAG_PRIORITY;
553+
http->flags |= NGHTTP3_HTTP_FLAG_BAD_PRIORITY;
554+
552555
return NGHTTP3_ERR_REMOVE_HTTP_HEADER;
553556
}
554557

@@ -992,7 +995,11 @@ int nghttp3_check_header_value(const uint8_t *value, size_t len) {
992995
case 0:
993996
return 1;
994997
case 1:
995-
return !is_ws(*value);
998+
if (is_ws(*value)) {
999+
return 0;
1000+
}
1001+
1002+
break;
9961003
default:
9971004
if (is_ws(*value) || is_ws(*(value + len - 1))) {
9981005
return 0;

0 commit comments

Comments
 (0)