diff --git a/include/shm-directory.h b/include/shm-directory.h index 1c0f9fcc89..8dc5befb96 100644 --- a/include/shm-directory.h +++ b/include/shm-directory.h @@ -28,8 +28,8 @@ struct shmdir_name { /* The combined prefix/name. The sizeof includes the terminating - NUL byte. 4 bytes are needed for the optional "sem." prefix. */ - char name[sizeof (SHMDIR) + 4 + NAME_MAX]; + NUL byte. */ + char name[sizeof (SHMDIR) + NAME_MAX]; }; /* Sets RESULT->name to the constructed name and returns 0 on success, diff --git a/posix/shm-directory.c b/posix/shm-directory.c index c1e9c6c434..b578ada580 100644 --- a/posix/shm-directory.c +++ b/posix/shm-directory.c @@ -58,11 +58,7 @@ __shm_get_name (struct shmdir_name *result, const char *name, bool sem_prefix) if (namelen == 0 || memchr (name, '/', namelen) != NULL) return EINVAL; if (alloc_buffer_has_failed (&buffer)) - { - if (namelen > NAME_MAX) - return ENAMETOOLONG; - return EINVAL; - } + return ENAMETOOLONG; return 0; } libc_hidden_def (__shm_get_name)