public inbox for libc-stable@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, committed 2.38] stdlib: Improve tst-realpath compatibility with source fortification
@ 2023-08-06 16:54 Andreas K. Hüttel
  0 siblings, 0 replies; only message in thread
From: Andreas K. Hüttel @ 2023-08-06 16:54 UTC (permalink / raw)
  To: libc-stable; +Cc: Andreas K . Huettel

From: Andreas K. Huettel <dilfridge@gentoo.org>

On GCC before 11, IPA can make the fortified realpath aware that the
buffer size is not large enough (8 bytes instead of PATH_MAX bytes).
Fix this by using a buffer that is large enough.

(cherry picked from commit 510fc20d73de12c85823d9996faac74666e9c2e7)
---
 stdlib/tst-realpath.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/stdlib/tst-realpath.c b/stdlib/tst-realpath.c
index f325c95a44..3694ecd8af 100644
--- a/stdlib/tst-realpath.c
+++ b/stdlib/tst-realpath.c
@@ -24,6 +24,7 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <malloc.h>
@@ -50,7 +51,11 @@ void dealloc (void *p)
 
 char* alloc (void)
 {
-  return (char *)malloc (8);
+#ifdef PATH_MAX
+  return (char *)malloc (PATH_MAX);
+#else
+  return (char *)malloc (4096);
+#endif
 }
 
 static int
-- 
2.41.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-06 16:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-06 16:54 [PATCH, committed 2.38] stdlib: Improve tst-realpath compatibility with source fortification Andreas K. Hüttel

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).