From 25af17c5873292cff4b26eda9f17f6a6870f9a92 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 11 Oct 2023 23:02:37 +0000 Subject: [PATCH] Clarify the fcntl() "that's not how F_SETFD works" error. The first app developer (we know of) that hit this didn't understand what it was trying to tell them. Before: FORTIFY: fcntl(F_SETFD) passed non-FD_CLOEXEC flag: 0x801 After: FORTIFY: fcntl(F_SETFD) only supports FD_CLOEXEC but was passed 0x801 Bug: https://issuetracker.google.com/304348746 Test: treehugger Change-Id: I8522e851d8f74c91152ebae68b083b5272d49255 --- libc/bionic/fcntl.cpp | 2 +- tests/fcntl_test.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libc/bionic/fcntl.cpp b/libc/bionic/fcntl.cpp index 754277b41..7730a150d 100644 --- a/libc/bionic/fcntl.cpp +++ b/libc/bionic/fcntl.cpp @@ -44,7 +44,7 @@ int fcntl(int fd, int cmd, ...) { va_end(args); if (cmd == F_SETFD && (reinterpret_cast(arg) & ~FD_CLOEXEC) != 0) { - __fortify_fatal("fcntl(F_SETFD) passed non-FD_CLOEXEC flag: %p", arg); + __fortify_fatal("fcntl(F_SETFD) only supports FD_CLOEXEC but was passed %p", arg); } #if defined(__LP64__) diff --git a/tests/fcntl_test.cpp b/tests/fcntl_test.cpp index b3be18eb8..47f3d91df 100644 --- a/tests/fcntl_test.cpp +++ b/tests/fcntl_test.cpp @@ -363,5 +363,5 @@ TEST(fcntl, open_O_TMPFILE_mode) { } TEST_F(fcntl_DeathTest, fcntl_F_SETFD) { - EXPECT_DEATH(fcntl(0, F_SETFD, O_NONBLOCK), "non-FD_CLOEXEC"); + EXPECT_DEATH(fcntl(0, F_SETFD, O_NONBLOCK), "only supports FD_CLOEXEC"); }