From 1bf5871aead6d73177d727add15ab0f14c258fdf Mon Sep 17 00:00:00 2001 From: "djm@openbsd.org" Date: Tue, 7 Jul 2026 04:04:16 +0000 Subject: [PATCH] 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;