@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix a Mercurial wire protocol parser issue when we receive a length frame before any data

Summary:
Depends on D18856. Ref T13036. See PHI275. When we receive a length frame but the buffer doesn't have any data yet, we currently emit a pointless 0-length data frame on the channel.

For normal chatter this is harmless/valid, but it causes problems when a channel has transitioned into bundle2 mode (probably it indicates "end of stream")?

In any case, it's never helpful, so if we're about to read a data block and don't have any data, just bail out until we see some more data.

Note that we can't end up here //expecting// a 0-length data block: both the `data-length` and `data-bytes` states already handle that properly.

Test Plan: Pushed 4MB changes to a Mercurial repository with Mercurial 4.1.1, was no longer able to hit channel errors.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13036

Differential Revision: https://secure.phabricator.com/D18857

+7
+7
src/applications/diffusion/ssh/DiffusionMercurialWireClientSSHProtocolChannel.php
··· 192 192 $this->state = 'data-bytes'; 193 193 } 194 194 } else if ($this->state == 'data-bytes') { 195 + // If we don't have any more bytes on the buffer yet, just bail: 196 + // otherwise, we'll emit a pointless and possibly harmful 0-byte data 197 + // frame. See T13036 for discussion. 198 + if (!strlen($this->buffer)) { 199 + break; 200 + } 201 + 195 202 $bytes = substr($this->buffer, 0, $this->expectBytes); 196 203 $this->buffer = substr($this->buffer, strlen($bytes)); 197 204 $this->expectBytes -= strlen($bytes);