mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] fix sem_unlink reporting wrong errno
@ 2024-10-29  3:01 lihua.zhao.cn
  0 siblings, 0 replies; only message in thread
From: lihua.zhao.cn @ 2024-10-29  3:01 UTC (permalink / raw)
  To: musl; +Cc: lihua.zhao.cn

From: Lihua Zhao <lihua.zhao.cn@windriver.com>

When the input name is invalid, it should set errno with ENOENT, but
this routine is also used by shm_open(), it set the errno with EINVAL.

Signed-off-by: Lihua Zhao <lihua.zhao.cn@windriver.com>
---
 src/mman/shm_open.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/mman/shm_open.c b/src/mman/shm_open.c
index 79784bd3..8383ffad 100644
--- a/src/mman/shm_open.c
+++ b/src/mman/shm_open.c
@@ -38,6 +38,10 @@ int shm_open(const char *name, int flag, mode_t mode)
 int shm_unlink(const char *name)
 {
 	char buf[NAME_MAX+10];
-	if (!(name = __shm_mapname(name, buf))) return -1;
+	if (!(name = __shm_mapname(name, buf))) {
+		if (errno == EINVAL) errno = ENOENT;
+		return -1;
+	}
+
 	return unlink(name);
 }
-- 
2.43.0


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

only message in thread, other threads:[~2024-10-29  3:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-29  3:01 [musl] [PATCH] fix sem_unlink reporting wrong errno lihua.zhao.cn

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).