This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Reject invalid definitions of _POSIX_CHOWN_RESTRICTED, _POSIX_NO_TRUNC, _POSIX_VDISABLE


On Sun, Jan 28, 2018 at 06:58:00PM +0100, Andreas Schwab wrote:
> POSIX requires that the constants _POSIX_CHOWN_RESTRICTED,
> _POSIX_NO_TRUNC, and _POSIX_VDISABLE are always defined to a value other
> than -1.
> 
> 	* sysdeps/posix/fpathconf.c (__fpathconf): Verify the values of
> 	_POSIX_CHOWN_RESTRICTED, _POSIX_NO_TRUNC, _POSIX_VDISABLE.
> 	* sysdeps/posix/pathconf.c (__pathconf): Likewise.
> ---
>  sysdeps/posix/fpathconf.c | 21 +++++++++------------
>  sysdeps/posix/pathconf.c  | 21 +++++++++------------
>  2 files changed, 18 insertions(+), 24 deletions(-)
> 
> diff --git a/sysdeps/posix/fpathconf.c b/sysdeps/posix/fpathconf.c
> index 80af77e148..a9d164564e 100644
> --- a/sysdeps/posix/fpathconf.c
> +++ b/sysdeps/posix/fpathconf.c
> @@ -103,25 +103,22 @@ __fpathconf (int fd, int name)
>  #endif
>  
>      case _PC_CHOWN_RESTRICTED:
> -#ifdef	_POSIX_CHOWN_RESTRICTED
> -      return _POSIX_CHOWN_RESTRICTED;
> -#else
> -      return -1;
> +#if _POSIX_CHOWN_RESTRICTED == -1
> +# error "Invalid value for _POSIX_CHOWN_RESTRICTED"
>  #endif
> +      return _POSIX_CHOWN_RESTRICTED;
>  
>      case _PC_NO_TRUNC:
> -#ifdef	_POSIX_NO_TRUNC
> -      return _POSIX_NO_TRUNC;
> -#else
> -      return -1;
> +#if _POSIX_NO_TRUNC == -1
> +# error "Invalid value for _POSIX_NO_TRUNC"
>  #endif
> +      return _POSIX_NO_TRUNC;
>  
>      case _PC_VDISABLE:
> -#ifdef	_POSIX_VDISABLE
> -      return _POSIX_VDISABLE;
> -#else
> -      return -1;
> +#if _POSIX_VDISABLE == -1
> +# error "Invalid value for _POSIX_VDISABLE"
>  #endif
> +      return _POSIX_VDISABLE;

sysdeps/mach/hurd/bits/posix_opt.h defines _POSIX_VDISABLE
to ((unsigned char) -1), should it be fixed, too?


-- 
ldv

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]