trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mas...@apache.org
Subject [trafficserver] branch master updated: h2spec: The endpoint MUST ignore any flags that is undefined.
Date Sat, 06 May 2017 02:35:30 GMT
This is an automated email from the ASF dual-hosted git repository.

maskit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/master by this push:
       new  0d39b4a   h2spec: The endpoint MUST ignore any flags that is undefined.
0d39b4a is described below

commit 0d39b4a2c07ae81954087acefeb029222a6381f2
Author: Zizhong Zhang <zizhang@linkedin.com>
AuthorDate: Mon May 1 18:01:56 2017 -0700

    h2spec: The endpoint MUST ignore any flags that is undefined.
---
 proxy/http2/HTTP2.cc | 24 +++++++-----------------
 proxy/http2/HTTP2.h  |  6 ------
 2 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/proxy/http2/HTTP2.cc b/proxy/http2/HTTP2.cc
index 31b013d..42a8c1b 100644
--- a/proxy/http2/HTTP2.cc
+++ b/proxy/http2/HTTP2.cc
@@ -124,25 +124,9 @@ memcpy_and_advance(uint8_t(&dst), byte_pointer &src)
   ++src.u8;
 }
 
-static bool
-http2_frame_flags_are_valid(uint8_t ftype, uint8_t fflags)
-{
-  if (ftype >= HTTP2_FRAME_TYPE_MAX) {
-    // Skip validation for Unkown frame type - [RFC 7540] 5.5. Extending HTTP/2
-    return true;
-  }
-
-  // The frame flags are valid for this frame if nothing outside the defined bits is set.
-  return (fflags & ~HTTP2_FRAME_FLAGS_MASKS[ftype]) == 0;
-}
-
 bool
 http2_frame_header_is_valid(const Http2FrameHeader &hdr, unsigned max_frame_size)
 {
-  if (!http2_frame_flags_are_valid(hdr.type, hdr.flags)) {
-    return false;
-  }
-
   // 6.1 If a DATA frame is received whose stream identifier field is 0x0, the recipient
MUST
   // respond with a connection error (Section 5.4.1) of type PROTOCOL_ERROR.
   if (hdr.type == HTTP2_FRAME_TYPE_DATA && hdr.streamid == 0) {
@@ -915,13 +899,19 @@ const static struct {
                                    {HTTP2_FRAME_TYPE_MAX, 0x40, true},
                                    {HTTP2_FRAME_TYPE_MAX, 0x80, true}};
 
+static const uint8_t HTTP2_FRAME_FLAGS_MASKS[HTTP2_FRAME_TYPE_MAX] = {
+  HTTP2_FLAGS_DATA_MASK,          HTTP2_FLAGS_HEADERS_MASK,      HTTP2_FLAGS_PRIORITY_MASK,
HTTP2_FLAGS_RST_STREAM_MASK,
+  HTTP2_FLAGS_SETTINGS_MASK,      HTTP2_FLAGS_PUSH_PROMISE_MASK, HTTP2_FLAGS_PING_MASK, 
   HTTP2_FLAGS_GOAWAY_MASK,
+  HTTP2_FLAGS_WINDOW_UPDATE_MASK, HTTP2_FLAGS_CONTINUATION_MASK,
+};
+
 REGRESSION_TEST(HTTP2_FRAME_FLAGS)(RegressionTest *t, int, int *pstatus)
 {
   TestBox box(t, pstatus);
   box = REGRESSION_TEST_PASSED;
 
   for (auto i : http2_frame_flags_test_case) {
-    box.check(http2_frame_flags_are_valid(i.ftype, i.fflags) == i.valid,
+    box.check((i.ftype >= HTTP2_FRAME_TYPE_MAX || (i.fflags & ~HTTP2_FRAME_FLAGS_MASKS[i.ftype])
== 0) == i.valid,
               "Validation of frame flags (type: %d, flags: %d) are expected %d, but not",
i.ftype, i.fflags, i.valid);
   }
 }
diff --git a/proxy/http2/HTTP2.h b/proxy/http2/HTTP2.h
index 96a8f38..34fd285 100644
--- a/proxy/http2/HTTP2.h
+++ b/proxy/http2/HTTP2.h
@@ -215,12 +215,6 @@ enum Http2FrameFlagsContinuation {
   HTTP2_FLAGS_CONTINUATION_MASK = 0x04,
 };
 
-static const uint8_t HTTP2_FRAME_FLAGS_MASKS[HTTP2_FRAME_TYPE_MAX] = {
-  HTTP2_FLAGS_DATA_MASK,          HTTP2_FLAGS_HEADERS_MASK,      HTTP2_FLAGS_PRIORITY_MASK,
HTTP2_FLAGS_RST_STREAM_MASK,
-  HTTP2_FLAGS_SETTINGS_MASK,      HTTP2_FLAGS_PUSH_PROMISE_MASK, HTTP2_FLAGS_PING_MASK, 
   HTTP2_FLAGS_GOAWAY_MASK,
-  HTTP2_FLAGS_WINDOW_UPDATE_MASK, HTTP2_FLAGS_CONTINUATION_MASK,
-};
-
 // [RFC 7540] 6.5.2. Defined SETTINGS Parameters
 enum Http2SettingsIdentifier {
   HTTP2_SETTINGS_HEADER_TABLE_SIZE      = 1,

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].

Mime
View raw message