public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: libc-alpha@sourceware.org
Subject: [PATCH 02/11] misc: Build gethostname with fortification
Date: Fri, 09 Feb 2024 16:24:54 +0100	[thread overview]
Message-ID: <f0bd7ca129f6dd3df2e9b03270e6fbd5990ace70.1707491940.git.fweimer@redhat.com> (raw)
In-Reply-To: <cover.1707491940.git.fweimer@redhat.com>

Introduce __glibc_nofortify_gethostname to request disabling
the fortification wrapper.
---
 misc/Makefile                               | 1 -
 misc/gethostname.c                          | 2 ++
 posix/bits/unistd.h                         | 3 ++-
 sysdeps/mach/hurd/gethostname.c             | 2 ++
 sysdeps/posix/gethostname.c                 | 2 ++
 sysdeps/unix/sysv/linux/alpha/gethostname.c | 2 ++
 6 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/misc/Makefile b/misc/Makefile
index 44ae89670a..6d8528c925 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -209,7 +209,6 @@ routines := \
 
 # Exclude fortified routines from being built with _FORTIFY_SOURCE
 routines_no_fortify += \
-  gethostname \
   syslog \
   # routines_no_fortify
 
diff --git a/misc/gethostname.c b/misc/gethostname.c
index 2c849a95c3..82800f8abb 100644
--- a/misc/gethostname.c
+++ b/misc/gethostname.c
@@ -15,6 +15,8 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#define __glibc_nofortify_gethostname
+
 #include <errno.h>
 #include <unistd.h>
 
diff --git a/posix/bits/unistd.h b/posix/bits/unistd.h
index 6ed2943bf1..1230bba9a5 100644
--- a/posix/bits/unistd.h
+++ b/posix/bits/unistd.h
@@ -138,7 +138,8 @@ getlogin_r (char *__buf, size_t __buflen)
 #endif
 
 
-#if defined __USE_MISC || defined __USE_UNIX98
+#if defined __USE_MISC || defined __USE_UNIX98 \
+  && !defined __glibc_nofortify_gethostname
 __fortify_function int
 __NTH (gethostname (char *__buf, size_t __buflen))
 {
diff --git a/sysdeps/mach/hurd/gethostname.c b/sysdeps/mach/hurd/gethostname.c
index 91d7f45d6e..dbb7d75713 100644
--- a/sysdeps/mach/hurd/gethostname.c
+++ b/sysdeps/mach/hurd/gethostname.c
@@ -15,6 +15,8 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#define __glibc_nofortify_gethostname
+
 #include <unistd.h>
 #include "hurdhost.h"
 
diff --git a/sysdeps/posix/gethostname.c b/sysdeps/posix/gethostname.c
index 3c50706b58..3c79f77dd3 100644
--- a/sysdeps/posix/gethostname.c
+++ b/sysdeps/posix/gethostname.c
@@ -15,6 +15,8 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#define __glibc_nofortify_gethostname
+
 #include <errno.h>
 #include <string.h>
 #include <unistd.h>
diff --git a/sysdeps/unix/sysv/linux/alpha/gethostname.c b/sysdeps/unix/sysv/linux/alpha/gethostname.c
index 30da8f30e4..45eb1788d4 100644
--- a/sysdeps/unix/sysv/linux/alpha/gethostname.c
+++ b/sysdeps/unix/sysv/linux/alpha/gethostname.c
@@ -15,6 +15,8 @@
    License along with the GNU C Library.  If not, see
    <https://www.gnu.org/licenses/>.  */
 
+#define __glibc_nofortify_gethostname
+
 #include <errno.h>
 #include <string.h>
 #include <unistd.h>
-- 
2.43.0



  parent reply	other threads:[~2024-02-09 15:24 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-09 15:24 [PATCH 00/11] Build getdomainname, gethostname, syslog " Florian Weimer
2024-02-09 15:24 ` [PATCH 01/11] misc: Build getdomainname " Florian Weimer
2024-02-12 17:14   ` Adhemerval Zanella Netto
2024-02-12 17:30     ` Andreas Schwab
2024-02-12 19:29       ` Florian Weimer
2024-02-13  9:12         ` Andreas Schwab
2024-02-13  9:23           ` Florian Weimer
2024-02-13  9:32             ` Andreas Schwab
2024-02-09 15:24 ` Florian Weimer [this message]
2024-02-12 17:25   ` [PATCH 02/11] misc: Build gethostname " Adhemerval Zanella Netto
2024-02-09 15:25 ` [PATCH 03/11] libio: Add fortify wrapper for internal __snprintf Florian Weimer
2024-02-12 17:34   ` Adhemerval Zanella Netto
2024-02-13 12:13     ` Florian Weimer
2024-02-13 13:16       ` Adhemerval Zanella Netto
2024-02-09 15:25 ` [PATCH 04/11] syslog: Update misc/tst-syslog to check reported %n value Florian Weimer
2024-02-13 11:59   ` Adhemerval Zanella Netto
2024-02-15 13:23     ` Florian Weimer
2024-02-09 15:25 ` [PATCH 05/11] syslog: Build with fortification Florian Weimer
2024-02-13 12:26   ` Adhemerval Zanella Netto
2024-02-09 15:25 ` [PATCH 06/11] stdio: Rename __printf_buffer to __vfprintf_buffer Florian Weimer
2024-02-16 13:40   ` Adhemerval Zanella Netto
2024-02-09 15:25 ` [PATCH 07/11] libio: Extract __printf_buffer_asprintf_init from asprintf implementation Florian Weimer
2024-02-16 14:04   ` Adhemerval Zanella Netto
2024-02-09 15:25 ` [PATCH 08/11] stdio-common: Introduce the __printf_buffer function Florian Weimer
2024-02-16 14:12   ` Adhemerval Zanella Netto
2024-02-09 15:25 ` [PATCH 09/11] stdio-common: Allow skipping initial bytes in __printf_buffer for %n Florian Weimer
2024-02-16 14:13   ` Adhemerval Zanella Netto
2024-02-09 15:25 ` [PATCH 10/11] stdio-common: Support large offsets with %lln Florian Weimer
2024-02-16 14:20   ` Adhemerval Zanella Netto
2024-02-09 15:26 ` [PATCH 11/11] syslog: Use a printf buffer directly to construct the entire packet Florian Weimer
2024-02-14 15:16   ` Adhemerval Zanella Netto
2024-02-15 13:02     ` Florian Weimer
2024-02-16 13:35       ` Adhemerval Zanella Netto
2024-02-16 15:58   ` Adhemerval Zanella Netto

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=f0bd7ca129f6dd3df2e9b03270e6fbd5990ace70.1707491940.git.fweimer@redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).