on master help sign in
Ignore late RST, WINDOW_UPDATE.

This commit addresses #639 by ignoring RST and WINDOW_UPDATE frames on a closed (or-implictly-closed) stream.

commit96b64fec020719b59bd4a2e041d475dfd813fe2c authorLucas DiCioccio <lucas@dicioccio.fr> dateSun 26 Aug 2018, 00:41 (8 years ago) parentd56cd4a
1 file changed+6−5
warp/Network/Wai/Handler/Warp/HTTP2/Receiver.hs+6−5
warp/Network/Wai/Handler/Warp/HTTP2/Receiver.hs+6−5
@@ -10,6 +10,7 @@ import Control.Concurrent
1010import Control.Concurrent.STM
1111import qualified Control.Exception as E
1212import qualified Data.ByteString as BS
13+import qualified Data.ByteString.Char8 as C8
1314import Data.IORef
1415import Network.HPACK
1516import Network.HPACK.Token
@@ -162,15 +163,15 @@ frameReceiver ctx mkreq recvN = loop 0 `E.catch` sendGoaway
162163 Nothing
163164 | isResponse streamId -> return Nothing
164165 | otherwise -> do
165− when (ftyp `notElem` [FrameHeaders,FramePriority]) $
166− E.throwIO $ ConnectionError ProtocolError "this frame is not allowed in an idel stream"
167166 csid <- readIORef clientStreamId
168− if streamId <= csid then
169− if ftyp == FramePriority then
167+ if streamId <= csid then -- consider the stream closed
168+ if ftyp `elem` [FrameWindowUpdate, FrameRSTStream, FramePriority] then
170169 return Nothing -- will be ignored
171170 else
172171 E.throwIO $ ConnectionError ProtocolError "stream identifier must not decrease"
173− else do
172+ else do -- consider the stream idle
173+ when (ftyp `notElem` [FrameHeaders,FramePriority]) $
174+ E.throwIO $ ConnectionError ProtocolError $ "this frame is not allowed in an idel stream: " `BS.append` C8.pack (show ftyp)
174175 when (ftyp == FrameHeaders) $ do
175176 writeIORef clientStreamId streamId
176177 cnt <- readIORef concurrency