From patchwork Sun Jan 28 17:58:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 866880 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-89739-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="e0LVKnbQ"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zV0jx09Jnz9t2x for ; Mon, 29 Jan 2018 04:58:12 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=t4YVJ9NNmjQoNvk3d0L+jm0xnRfK6 nDLfsc6dGRQSfyIJNfIFfCU0rbnjaRkLnL2TAi/9cnWx4jw8u+PMYDwoBRvYIpOb 3CuHYsqKO42tvw0h47Y9s3QiQ4ksZebRqtegdGssTjt+Z+QXYbTUv4Gu+bBTRRHM AgOq61rJoHbTlE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; s=default; bh=RfsEk73TbF1ENfmVWA/mLY7Xmc4=; b=e0L VKnbQgJQ4XcI8RONKIDcQPL/HRSkwp0F9ktC3ZVDuVR0atnLOl7YYH/FV1AMUxuS Tr6jy+zCaodwOyfyFO8DENixq6EeBSmu/Y53Z5g6qUb+TwxEUm1NxjWpB9cZkULU eNkBvsBslJCDOYoMpn7SWAdC74CcTZ8gaBa26Md4= Received: (qmail 84314 invoked by alias); 28 Jan 2018 17:58:07 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 84304 invoked by uid 89); 28 Jan 2018 17:58:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=10322, 10325 X-HELO: mail-out.m-online.net X-Auth-Info: sy8LBmEsQV47Q6bw7PlSIO42qGQy/lVqlYMiy84CgGxxyzp/k0TqWMxdM4L7VEJK From: Andreas Schwab To: libc-alpha@sourceware.org Subject: [PATCH] Reject invalid definitions of _POSIX_CHOWN_RESTRICTED, _POSIX_NO_TRUNC, _POSIX_VDISABLE X-Yow: SHHHH!! I hear SIX TATTOOED TRUCK-DRIVERS tossing ENGINE BLOCKS into empty OIL DRUMS.. Date: Sun, 28 Jan 2018 18:58:00 +0100 Message-ID: <87o9ld3lxz.fsf@linux-m68k.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.91 (gnu/linux) MIME-Version: 1.0 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; case _PC_SYNC_IO: #ifdef _POSIX_SYNC_IO diff --git a/sysdeps/posix/pathconf.c b/sysdeps/posix/pathconf.c index 2059e55b4f..0f893ec1ba 100644 --- a/sysdeps/posix/pathconf.c +++ b/sysdeps/posix/pathconf.c @@ -101,25 +101,22 @@ __pathconf (const char *path, 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; case _PC_SYNC_IO: #ifdef _POSIX_SYNC_IO