Skip to content

Commit 41c3036

Browse files
committed
Provide headroom for channel input buffer.
/* we need to reserve a small amount of overhead on the input buffer * or we can enter into a pathological state during bulk * data transfers. We use a fraction of the max size as we want it to scale * with the size of the input buffer. If we do it for all of the buffers * we fail the regression unit tests. This seems like a reasonable * solution. Of course, I still need to figure out *why* this is * happening and come up with an actual fix. TODO * cjr 4/19/2024 */
1 parent edb2bea commit 41c3036

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

sshbuf.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,18 @@ sshbuf_avail(const struct sshbuf *buf)
318318
{
319319
if (sshbuf_check_sanity(buf) != 0 || buf->readonly || buf->refcount > 1)
320320
return 0;
321-
return buf->max_size - (buf->size - buf->off);
321+
/* we need to reserve a small amount of overhead on the input buffer
322+
* or we can enter into a pathological state during bulk
323+
* data transfers. We use a fraction of the max size as we want it to scale
324+
* with the size of the input buffer. If we do it for all of the buffers
325+
* we fail the regression unit tests. This seems like a reasonable
326+
* solution. Of course, I still need to figure out *why* this is
327+
* happening and come up with an actual fix. TODO
328+
* cjr 4/19/2024 */
329+
if (buf->type == BUF_CHANNEL_INPUT)
330+
return buf->max_size / 1.05 - (buf->size - buf->off);
331+
else
332+
return buf->max_size - (buf->size - buf->off);
322333
}
323334

324335
const u_char *

0 commit comments

Comments
 (0)