[PATCH 2/6] sysvipc: Return EINVAL for invalid semctl commands

Florian Weimer fweimer@redhat.com
Mon Sep 28 16:33:57 GMT 2020


* Adhemerval Zanella via Libc-alpha:

> diff --git a/sysdeps/unix/sysv/linux/semctl.c b/sysdeps/unix/sysv/linux/semctl.c
> index 1cdabde8f2..dcff6e691d 100644
> --- a/sysdeps/unix/sysv/linux/semctl.c
> +++ b/sysdeps/unix/sysv/linux/semctl.c
> @@ -158,6 +158,15 @@ __semctl64 (int semid, int semnum, int cmd, ...)
>        arg64 = va_arg (ap, union semun64);
>        va_end (ap);
>        break;
> +    case IPC_RMID:      /* arg ignored. */

Missing space after “.”.

> +/* Return the first invalid command SysV IPC command for shared memory.  */
> +static inline int
> +first_shm_invalid_cmd (void)
> +{
> +  const int shm_cmds[] = {
> +    SHM_STAT,
> +    SHM_INFO,
> +#ifdef SHM_STAT_ANY
> +    SHM_STAT_ANY,
> +#endif
> +  };
> +
> +  int invalid = first_common_invalid_cmd ();
> +  for (int i = 0; i < array_length (shm_cmds); i++)
> +    {
> +      if (invalid == shm_cmds[i])
> +	{
> +	  invalid++;
> +	  i = 0;
> +	}
> +    }
> +
> +  return invalid;
> +}

I think this change should go into the shmctl patch?  Maybe add the
tests separately at the end? 

Rest looks okay to me.

Thanks,
Florian
-- 
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill



More information about the Libc-alpha mailing list