Skip to content

Commit 7de2ccc

Browse files
authored
fix panic when receiving already reset push promise (#597)
Found by oss-fuzz
1 parent a28a39c commit 7de2ccc

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/proto/streams/recv.rs

+10
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,16 @@ impl Recv {
786786
}
787787
}
788788

789+
pub(super) fn maybe_reset_next_stream_id(&mut self, id: StreamId) {
790+
if let Ok(next_id) = self.next_stream_id {
791+
// !Peer::is_local_init should have been called beforehand
792+
debug_assert_eq!(id.is_server_initiated(), next_id.is_server_initiated());
793+
if id >= next_id {
794+
self.next_stream_id = id.next_id();
795+
}
796+
}
797+
}
798+
789799
/// Returns true if the remote peer can reserve a stream with the given ID.
790800
pub fn ensure_can_reserve(&self) -> Result<(), Error> {
791801
if !self.is_push_enabled {

src/proto/streams/streams.rs

+4
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,10 @@ impl Inner {
883883
// We normally would open this stream, so update our
884884
// next-send-id record.
885885
self.actions.send.maybe_reset_next_stream_id(id);
886+
} else {
887+
// We normally would recv this stream, so update our
888+
// next-recv-id record.
889+
self.actions.recv.maybe_reset_next_stream_id(id);
886890
}
887891

888892
let stream = Stream::new(id, 0, 0);

0 commit comments

Comments
 (0)