Skip to content

Commit 345a450

Browse files
committed
Checkpoint
1 parent 5653676 commit 345a450

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

regress/unittests/sshbuf/test_sshbuf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ sshbuf_tests(void)
176176
ASSERT_SIZE_T_EQ(sshbuf_len(p1), 1223);
177177
ASSERT_SIZE_T_EQ(sshbuf_avail(p1), 0);
178178
r = sshbuf_reserve(p1, 1, &dp);
179+
/* this test is currently failing. This will
180+
* be addressed ASAP. TODO. cjr 4/18/24 */
179181
ASSERT_INT_EQ(r, SSH_ERR_NO_BUFFER_SPACE);
180182
ASSERT_PTR_EQ(dp, NULL);
181183
TEST_DONE();

sshbuf.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,9 @@ sshbuf_check_reserve(const struct sshbuf *buf, size_t len)
367367
if (buf->readonly || buf->refcount > 1)
368368
return SSH_ERR_BUFFER_READ_ONLY;
369369
SSHBUF_TELL("check");
370-
/* Check that len is reasonable and that max size + available < len */
371-
/* prior we'd check ((buf->max_size / 2) - len) */
372-
/* cjr 4/17/24 */
373-
if ((len > (buf->max_size / 2) ||
374-
((buf->max_size - len) < (buf->size - buf->off))))
375-
return SSH_ERR_NO_BUFFER_SPACE;
370+
/* Check that len is reasonable and that max_size + available < len */
371+
if (len > buf->max_size || buf->max_size - len < buf->size - buf->off)
372+
return SSH_ERR_NO_BUFFER_SPACE;
376373
return 0;
377374
}
378375

@@ -426,7 +423,7 @@ sshbuf_allocate(struct sshbuf *buf, size_t len)
426423
* Turns out the extra functions on the following conditional aren't needed
427424
* -cjr 04/06/23
428425
*/
429-
if (rlen > BUF_WATERSHED && buf->type == BUF_CHANNEL_INPUT) {
426+
if (rlen > BUF_WATERSHED) { // && (buf->type == BUF_CHANNEL_INPUT || buf->type == BUF_CHANNEL_OUTPUT)) {
430427
/* debug_f ("Prior: label: %s, %p, rlen is %zu need is %zu win_max is %zu max_size is %zu", */
431428
/* buf->label, buf, rlen, need, buf->window_max, buf->max_size); */
432429
/* easiest thing to do is grow the nuffer by 4MB each time. It might end
@@ -436,14 +433,14 @@ sshbuf_allocate(struct sshbuf *buf, size_t len)
436433
/* debug_f ("Post: label: %s, %p, rlen is %zu need is %zu win_max is %zu max_size is %zu", */
437434
/* buf->label, buf, rlen, need, buf->window_max, buf->max_size); */
438435
}
439-
if (rlen > BUF_WATERSHED && buf->type == BUF_CHANNEL_OUTPUT) {
440-
/* debug_f ("Pre: label: %s, %p, rlen is %zu need is %zu win_max is %zu max_size is %zu", */
441-
/* buf->label, buf, rlen, need, buf->window_max, buf->max_size); */
442-
need = (4*1024*1024);
443-
rlen = ROUNDUP(buf->alloc + need, SSHBUF_SIZE_INC);
444-
/* debug_f ("Post: label: %s, %p, rlen is %zu need is %zu win_max is %zu max_size is %zu", */
445-
/* buf->label, buf, rlen, need, buf->window_max, buf->max_size); */
446-
}
436+
/* if (rlen > BUF_WATERSHED && buf->type == BUF_CHANNEL_OUTPUT) { */
437+
/* /\* debug_f ("Pre: label: %s, %p, rlen is %zu need is %zu win_max is %zu max_size is %zu", *\/ */
438+
/* /\* buf->label, buf, rlen, need, buf->window_max, buf->max_size); *\/ */
439+
/* need = (4*1024*1024); */
440+
/* rlen = ROUNDUP(buf->alloc + need, SSHBUF_SIZE_INC); */
441+
/* /\* debug_f ("Post: label: %s, %p, rlen is %zu need is %zu win_max is %zu max_size is %zu", *\/ */
442+
/* /\* buf->label, buf, rlen, need, buf->window_max, buf->max_size); *\/ */
443+
/* } */
447444
SSHBUF_DBG(("need %zu initial rlen %zu", need, rlen));
448445

449446
/* rlen might be above the max allocation */

0 commit comments

Comments
 (0)