public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] stdlib: Improve tst-realpath compatibility with source fortification
@ 2023-07-28 13:33 Florian Weimer
  2023-07-28 19:01 ` Siddhesh Poyarekar
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Weimer @ 2023-07-28 13:33 UTC (permalink / raw)
  To: libc-alpha; +Cc: Carlos O'Donell, Frederic Berat

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.

Tested with GCC 8 and GCC 11 on x86_64-linux-gnu with and without
fortification.  Built with build-many-glibcs.py.  This probably should
not be part of the upcoming release because it's just a test failure, it
does not even break the test build.

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

base-commit: 14126ff059e98e9236633741fd323a1116299872


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] stdlib: Improve tst-realpath compatibility with source fortification
  2023-07-28 13:33 [PATCH] stdlib: Improve tst-realpath compatibility with source fortification Florian Weimer
@ 2023-07-28 19:01 ` Siddhesh Poyarekar
  0 siblings, 0 replies; 2+ messages in thread
From: Siddhesh Poyarekar @ 2023-07-28 19:01 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha; +Cc: Carlos O'Donell, Frederic Berat

On 2023-07-28 09:33, Florian Weimer via Libc-alpha wrote:
> 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.
> 
> Tested with GCC 8 and GCC 11 on x86_64-linux-gnu with and without
> fortification.  Built with build-many-glibcs.py.  This probably should
> not be part of the upcoming release because it's just a test failure, it
> does not even break the test build.

LGTM.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

> ---
>   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
> 
> base-commit: 14126ff059e98e9236633741fd323a1116299872
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-28 19:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-28 13:33 [PATCH] stdlib: Improve tst-realpath compatibility with source fortification Florian Weimer
2023-07-28 19:01 ` Siddhesh Poyarekar

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