1 Star 0 Fork 15

wynn_personnal/glibc

forked from OpenCloudOS Stream/glibc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-rt-fix-shm_open-not-set-ENAMETOOLONG-when-name-excee.patch 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
nilusyi 提交于 2023-06-01 10:41 . update
From 7ec262097d7181945e4ea95a428d1de2bddc8b63 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Thu, 9 Mar 2023 09:58:20 +0800
Subject: [PATCH]
backport-rt-fix-shm_open-not-set-ENAMETOOLONG-when-name-excee.patch
---
posix/shm-directory.c | 12 +++++++++---
rt/shm_open.c | 5 +++--
sysdeps/pthread/sem_open.c | 5 +++--
3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/posix/shm-directory.c b/posix/shm-directory.c
index 76ea825b..d944bb20 100644
--- a/posix/shm-directory.c
+++ b/posix/shm-directory.c
@@ -23,6 +23,7 @@
#include <alloc_buffer.h>
#include <shm-directory.h>
#include <string.h>
+#include <errno.h>
int
__shm_get_name (struct shmdir_name *result, const char *name, bool sem_prefix)
@@ -37,9 +38,14 @@ __shm_get_name (struct shmdir_name *result, const char *name, bool sem_prefix)
if (sem_prefix)
alloc_buffer_copy_bytes (&buffer, "sem.", strlen ("sem."));
alloc_buffer_copy_bytes (&buffer, name, namelen + 1);
- if (namelen == 0 || memchr (name, '/', namelen) != NULL
- || alloc_buffer_has_failed (&buffer))
- return -1;
+ if (namelen == 0 || memchr (name, '/', namelen) != NULL)
+ return EINVAL;
+ if (alloc_buffer_has_failed (&buffer))
+ {
+ if (namelen > NAME_MAX)
+ return ENAMETOOLONG;
+ return EINVAL;
+ }
return 0;
}
libc_hidden_def (__shm_get_name)
diff --git a/rt/shm_open.c b/rt/shm_open.c
index 11cb7cc7..2a061d1c 100644
--- a/rt/shm_open.c
+++ b/rt/shm_open.c
@@ -29,9 +29,10 @@ int
__shm_open (const char *name, int oflag, mode_t mode)
{
struct shmdir_name dirname;
- if (__shm_get_name (&dirname, name, false) != 0)
+ int ret =__shm_get_name (&dirname, name, false);
+ if (ret != 0)
{
- __set_errno (EINVAL);
+ __set_errno (ret);
return -1;
}
diff --git a/sysdeps/pthread/sem_open.c b/sysdeps/pthread/sem_open.c
index add01d56..c9c565dd 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;
}
--
2.36.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wynn_personnal/glibc.git
git@gitee.com:wynn_personnal/glibc.git
wynn_personnal
glibc
glibc
master

搜索帮助