[openssh-commits] [openssh] 06/14: upstream: have sshbuf_read_fd() pre-allocate its sshbuf using the

git+noreply at mindrot.org git+noreply at mindrot.org
Thu Nov 26 10:20:51 AEDT 2026


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit f91468b59ab803fa2740b5fadba76857214876db
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Wed Nov 25 21:02:17 2026 +0000

    upstream: have sshbuf_read_fd() pre-allocate its sshbuf using the
    
    size we got from fstat()
    
    Anthropic ANT-2026-LVH1585F
    
    OpenBSD-Commit-ID: ae795b2c803eab1e42fe56cf8e99ac0e7307d657
---
 sshbuf-io.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sshbuf-io.c b/sshbuf-io.c
index 426b7e234..9eefc6242 100644
--- a/sshbuf-io.c
+++ b/sshbuf-io.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: sshbuf-io.c,v 1.4 2026/07/05 00:16:21 djm Exp $ */
+/*	$OpenBSD: sshbuf-io.c,v 1.5 2026/11/25 21:02:17 djm Exp $ */
 /*
  * Copyright (c) 2011 Damien Miller
  *
@@ -47,6 +47,9 @@ sshbuf_load_fd(int fd, struct sshbuf **blobp)
 		return SSH_ERR_INVALID_FORMAT;
 	if ((blob = sshbuf_new()) == NULL)
 		return SSH_ERR_ALLOC_FAIL;
+	if (S_ISREG(st.st_mode) && st.st_size > 0 &&
+	    (r = sshbuf_allocate(blob, st.st_size)) != 0)
+		goto out;
 	for (;;) {
 		if ((len = atomicio(read, fd, buf, sizeof(buf))) == 0) {
 			if (errno == EPIPE)

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list