mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] mman: correct length check in __shm_mapname
@ 2024-11-05  1:06 lihua.zhao.cn
  2024-11-05  1:46 ` Rich Felker
  0 siblings, 1 reply; 7+ messages in thread
From: lihua.zhao.cn @ 2024-11-05  1:06 UTC (permalink / raw)
  To: musl; +Cc: lihua.zhao.cn

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

changed the length check from `p-name > NAME_MAX` to
`p-name >= NAME_MAX` to correctly account for the null terminator.

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

diff --git a/src/mman/shm_open.c b/src/mman/shm_open.c
index 79784bd3..2359f067 100644
--- a/src/mman/shm_open.c
+++ b/src/mman/shm_open.c
@@ -15,7 +15,7 @@ char *__shm_mapname(const char *name, char *buf)
 		errno = EINVAL;
 		return 0;
 	}
-	if (p-name > NAME_MAX) {
+	if (p-name >= NAME_MAX) {
 		errno = ENAMETOOLONG;
 		return 0;
 	}
-- 
2.43.0


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

end of thread, other threads:[~2024-11-05  6:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-05  1:06 [musl] [PATCH] mman: correct length check in __shm_mapname lihua.zhao.cn
2024-11-05  1:46 ` Rich Felker
2024-11-05  2:03   ` Zhao, Lihua (CN)
2024-11-05  3:00     ` Rich Felker
2024-11-05  4:56       ` [musl] [PATCH v2] " lihua.zhao.cn
2024-11-05  5:15         ` Rich Felker
2024-11-05  6:06           ` Zhao, Lihua (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).