[openssh-commits] [openssh] 01/12: upstream: prefer fstat to stat when it's trivial to do so

git+noreply at mindrot.org git+noreply at mindrot.org
Tue Jul 21 15:23:30 AEST 2026


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

djm pushed a commit to branch master
in repository openssh.

commit 1bf5871aead6d73177d727add15ab0f14c258fdf
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Tue Jul 7 04:04:16 2026 +0000

    upstream: prefer fstat to stat when it's trivial to do so
    
    OpenBSD-Commit-ID: 3af5548ba2112045db392a14c959ca309605bdb9
---
 authfile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/authfile.c b/authfile.c
index 954f78c00..be2410599 100644
--- a/authfile.c
+++ b/authfile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: authfile.c,v 1.151 2026/06/29 09:14:25 djm Exp $ */
+/* $OpenBSD: authfile.c,v 1.152 2026/07/07 04:04:16 djm Exp $ */
 /*
  * Copyright (c) 2000, 2013 Markus Friedl.  All rights reserved.
  *
@@ -207,7 +207,7 @@ sshkey_try_load_public(struct sshkey **kp, const char *filename,
 		*commentp = NULL;
 	if ((f = fopen(filename, "r")) == NULL)
 		return SSH_ERR_SYSTEM_ERROR;
-	if (stat(filename, &st) == 0 && S_ISREG(st.st_mode) &&
+	if (fstat(fileno(f), &st) == 0 && S_ISREG(st.st_mode) &&
 	    st.st_size > SSHBUF_SIZE_MAX) {
 		fclose(f);
 		return SSH_ERR_INVALID_FORMAT;

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


More information about the openssh-commits mailing list