summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2021-03-24 01:36:20 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2021-03-24 21:58:05 +0100
commit4631c2372a40c8f9e4b6da863a456c8de8b448a6 (patch)
tree1698e8da989831824dd8ff8a44837de816bdd674 /stdlib
parent16b597807d6c383c6a4730fe27e143271e952edb (diff)
downloadglibc-4631c2372a40c8f9e4b6da863a456c8de8b448a6.tar.gz
glibc-4631c2372a40c8f9e4b6da863a456c8de8b448a6.tar.xz
glibc-4631c2372a40c8f9e4b6da863a456c8de8b448a6.zip
stdlib: Fix BZ #26241 testcase on GNU/Hurd
GNU/Hurd's readlink system call is partly implemented in userspace, which
also allocates a buffer on the stack for the result, and thus needs one
more path.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/tst-canon-bz26341.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/stdlib/tst-canon-bz26341.c b/stdlib/tst-canon-bz26341.c
index 6d054596b5..acb0fd4ec3 100644
--- a/stdlib/tst-canon-bz26341.c
+++ b/stdlib/tst-canon-bz26341.c
@@ -67,15 +67,16 @@ do_realpath (void *arg)
      for each symlink in the path, leading to MAXSYMLINKS times PATH_MAX
      maximum stack usage.
      This stack allocations tries fill the thread allocated stack minus
-     both the resolved path (plus some slack) and the realpath (plus some
-     slack).
+     the resolved path (plus some slack), the realpath (plus some
+     slack), and the system call usage (plus some slack).
      If realpath uses more than 2 * PATH_MAX plus some slack it will trigger
      a stackoverflow.  */
 
+  const size_t syscall_usage = 1 * PATH_MAX + 1024;
   const size_t realpath_usage = 2 * PATH_MAX + 1024;
   const size_t thread_usage = 1 * PATH_MAX + 1024;
   size_t stack_size = support_small_thread_stack_size ()
-		      - realpath_usage - thread_usage;
+		      - syscall_usage - realpath_usage - thread_usage;
   char stack[stack_size];
   char *resolved = stack + stack_size - thread_usage + 1024;