From: "AZero13 via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: AZero13 <gfunni234@gmail.com>, AZero13 <gfunni234@gmail.com>
Subject: [PATCH] open: check fd_flags value before calling fcntl
Date: Thu, 18 Dec 2025 03:14:03 +0000 [thread overview]
Message-ID: <pull.2131.git.git.1766027643744.gitgitgadget@gmail.com> (raw)
From: AZero13 <gfunni234@gmail.com>
Otherwise, fcntl can be called with invalid fd_flags.
Signed-off-by: Greg Funni <gfunni234@gmail.com>
---
open: check fd_flags value before calling fcntl
Otherwise, fcntl can be called with invalid fd_flags.
Signed-off-by:Greg Funni gfunni234@gmail.com
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2131%2FAZero13%2Ffixopen-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2131/AZero13/fixopen-v1
Pull-Request: https://github.com/git/git/pull/2131
compat/open.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/compat/open.c b/compat/open.c
index 37ae2b1aeb..b313bcd364 100644
--- a/compat/open.c
+++ b/compat/open.c
@@ -44,8 +44,8 @@ int git_open_cloexec(const char *name, int flags)
if (!o_cloexec && 0 <= fd && fd_cloexec) {
/* Opened w/o O_CLOEXEC? try with fcntl(2) to add it */
- int flags = fcntl(fd, F_GETFD);
- if (fcntl(fd, F_SETFD, flags | fd_cloexec))
+ int fd_flags = fcntl(fd, F_GETFD);
+ if (fd_flags < 0 || fcntl(fd, F_SETFD, fd_flags | fd_cloexec))
fd_cloexec = 0;
}
}
base-commit: c4a0c8845e2426375ad257b6c221a3a7d92ecfda
--
gitgitgadget
next reply other threads:[~2025-12-18 3:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-18 3:14 AZero13 via GitGitGadget [this message]
2025-12-18 3:45 ` [PATCH] open: check fd_flags value before calling fcntl Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.2131.git.git.1766027643744.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=gfunni234@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).