From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: libc-alpha@sourceware.org
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>, commit-hurd@gnu.org
Subject: [hurd,commited 2/4] Subject: hurd: Make __realpath return EINVAL on NULL buf
Date: Thu, 3 Aug 2023 22:48:25 +0200 [thread overview]
Message-ID: <20230803204827.1193126-3-samuel.thibault@ens-lyon.org> (raw)
In-Reply-To: <20230803204827.1193126-1-samuel.thibault@ens-lyon.org>
As Posix and stdlib/test-canon.c expects it, and rather than letting
pathconf crash.
---
debug/realpath_chk.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/debug/realpath_chk.c b/debug/realpath_chk.c
index adfc09237c..8e734b534e 100644
--- a/debug/realpath_chk.c
+++ b/debug/realpath_chk.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <errno.h>
char *
@@ -30,7 +31,15 @@ __realpath_chk (const char *buf, char *resolved, size_t resolvedlen)
return __realpath (buf, resolved);
#else
- long int pathmax =__pathconf (buf, _PC_PATH_MAX);
+ long int pathmax;
+
+ if (buf == NULL)
+ {
+ __set_errno (EINVAL);
+ return NULL;
+ }
+
+ pathmax = __pathconf (buf, _PC_PATH_MAX);
if (pathmax != -1)
{
/* We do have a fixed limit. */
--
2.40.1
next prev parent reply other threads:[~2023-08-03 20:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-03 20:48 [hurd,commited 0/4] i686-gnu fixes against fortification Samuel Thibault
2023-08-03 20:48 ` [hurd,commited 1/4] tst-*glob*: Do not check d_name size Samuel Thibault
2023-08-03 20:48 ` Samuel Thibault [this message]
2023-08-03 20:48 ` [hurd,commited 3/4] tst-realpath-toolong: return "unsupported" when PATH_MAX is undefined Samuel Thibault
2023-08-03 20:48 ` [hurd,commited 4/4] chk: Add and fix hidden builtin definitions for *_chk Samuel Thibault
2023-08-06 17:56 ` [hurd, commited " Sam James
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=20230803204827.1193126-3-samuel.thibault@ens-lyon.org \
--to=samuel.thibault@ens-lyon.org \
--cc=commit-hurd@gnu.org \
--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).