about summary refs log tree commit diff
path: root/sysdeps/pthread
diff options
context:
space:
mode:
authorabushwang <abushwangs@gmail.com>2023-03-07 20:16:20 +0800
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-03-08 10:11:54 -0300
commit0b7bf0e0a486da6be7c5dde742a80c1138f9cc89 (patch)
treeecacffd3daf24ed95b374a8710e390a66723706b /sysdeps/pthread
parent65387e48097077c71ed527457c59ba59f3a1f3ee (diff)
downloadglibc-0b7bf0e0a486da6be7c5dde742a80c1138f9cc89.tar.gz
glibc-0b7bf0e0a486da6be7c5dde742a80c1138f9cc89.tar.xz
glibc-0b7bf0e0a486da6be7c5dde742a80c1138f9cc89.zip
rt: fix shm_open not set ENAMETOOLONG when name exceeds {_POSIX_PATH_MAX}
according to man-pages-posix-2017, shm_open() function may fail if the length
of the name argument exceeds {_POSIX_PATH_MAX} and set ENAMETOOLONG

Signed-off-by: abushwang <abushwangs@gmail.com>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/pthread')
-rw-r--r--sysdeps/pthread/sem_open.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sysdeps/pthread/sem_open.c b/sysdeps/pthread/sem_open.c
index 2551b035e1..2d32a13557 100644
--- a/sysdeps/pthread/sem_open.c
+++ b/sysdeps/pthread/sem_open.c
@@ -47,9 +47,10 @@ __sem_open (const char *name, int oflag, ...)
     }
 
   struct shmdir_name dirname;
-  if (__shm_get_name (&dirname, name, true) != 0)
+  int ret = __shm_get_name (&dirname, name, true);
+  if (ret != 0)
     {
-      __set_errno (EINVAL);
+      __set_errno (ret);
       return SEM_FAILED;
     }