From patchwork Thu Nov 30 21:39:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaakov Selkowitz X-Patchwork-Id: 120279 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp330320qgn; Thu, 30 Nov 2017 13:40:01 -0800 (PST) X-Google-Smtp-Source: AGs4zMbnCKzXqp1XdZ8HNqz65NVRguEHaCo7gbTyVsmP9odguGPwCLKaEKzEY0UJpVmvEC4TOjdE X-Received: by 10.99.125.71 with SMTP id m7mr3728246pgn.349.1512078001580; Thu, 30 Nov 2017 13:40:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512078001; cv=none; d=google.com; s=arc-20160816; b=eXy2fVosqRACM597UqMXZS2uPljqqcFOylKt1yEv/zc+UYaVHSecfhoCOjjbj6LcQU pnJlGNTwk9hE0eoCK6FkPnaZhb7t9RrVtPSKNsb9Jd6Ppn+tKfrr1/HqGV5nawvaWTnQ DWcHlRT7TuVbO5w/eWdITwegAqgcpnr6IxyQVhWEX4+327s5CUDb+QjMoyNYORZ3+Uuu 1sY+HZbfIF381TQAbDvj/N7fUuhDRnb4DWjlwI12f4X/e5txaF2ctiiieUVDI4iub2cw rrH60wDbyoXeOCTaRLhj8PP2E/YfJE9/m8NsYvCClHnS25WC9Us+Rqs/kK3lwMaVfb3C sRaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=OK4kzBoFr9JRN0fma7iHOSecfrI5Kyvyk4of+PzRrzE=; b=DWaDr37iaJP/f56wtD0ISWIKS5tpPAwtfUjX0ap7z688KsjUzNSsGlkWjzi7IzJ4kp PhyTFVfaxbQvzUP4drTNOgGYpMbkbVT4y2JOcTeHYLzEDY2MQk0XE6Pi/TGMdIF/XNL7 VDH9IFsUXdubi204TS7QL6GEhoOI+vjAJt7rvS0PdJhxWj8aljqffrbp7PmuUL3/QHeJ BRYvbdooK+4GjpVHYoW2TNUwcClNAHBqK4EOeNA8RI3YxTouuWE6IoKu2LBTzKh6IhhQ 3Sb16pPq+O/Dag2VGfRefr1quym2g/uZx1Gq2wSZXmzzWlA3XDDw812/Q5iKtIhiEfuO RuFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=PAnPp1Yw; spf=pass (google.com: domain of newlib-return-15450-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15450-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id k29si3906926pfg.316.2017.11.30.13.40.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Nov 2017 13:40:01 -0800 (PST) Received-SPF: pass (google.com: domain of newlib-return-15450-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=PAnPp1Yw; spf=pass (google.com: domain of newlib-return-15450-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15450-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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; q=dns; s= default; b=UgmiGcQuwIkwEg8DoL02ZsuXZk9zOISQdCEo/wAQY4QRq4lTmhRbV MqVHcRCnXERQPDF2NLet2j+dtSDBnFCe8dB1m4gYlNoTCY1SfyV5dRt8wZGstCxT 1Zq+6K/VkacF3LwRCCsonP2++tY8QiZhwu8BHSgrV91saW8Xe+wp64= 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; s=default; bh=1SW26T2iSUMfwkrjz/v4x1KwdDw=; b=PAnPp1YwoGgccTph2uZJe21XwZy3 7lVtEH2QS8T6UE3xVNnxG4xfwH7D5bevnmZ/UK6ih4RjAbsjQShp3L5fwUhynh5u Yrv3ivgTtdpcuSdVPANCGEyFvjWXrcF2PT3NEo26iTBIBevM8K2/kHaVj/Ypas2U O1igROmxwqh27C0= Received: (qmail 75459 invoked by alias); 30 Nov 2017 21:39:52 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 75434 invoked by uid 89); 30 Nov 2017 21:39:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, KB_WAM_FROM_NAME_SINGLEWORD, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 Nov 2017 21:39:50 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 540515D9E7 for ; Thu, 30 Nov 2017 21:39:49 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-45.phx2.redhat.com [10.3.116.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F6E15D6A3 for ; Thu, 30 Nov 2017 21:39:48 +0000 (UTC) From: Yaakov Selkowitz To: newlib@sourceware.org Subject: [PATCH] ssp: add Object Size Checking for unistd.h, part 2 Date: Thu, 30 Nov 2017 15:39:37 -0600 Message-Id: <20171130213937.21064-1-yselkowi@redhat.com> Signed-off-by: Yaakov Selkowitz --- newlib/libc/include/ssp/unistd.h | 44 ++++++++++++++++++++++++++++++++++++++-- newlib/libc/ssp/ssp.tex | 3 ++- 2 files changed, 44 insertions(+), 3 deletions(-) -- 2.15.0 diff --git a/newlib/libc/include/ssp/unistd.h b/newlib/libc/include/ssp/unistd.h index 861edd30b..5ca6ace7a 100644 --- a/newlib/libc/include/ssp/unistd.h +++ b/newlib/libc/include/ssp/unistd.h @@ -36,6 +36,40 @@ #if __SSP_FORTIFY_LEVEL > 0 __BEGIN_DECLS +#if __POSIX_VISIBLE >= 199209 +__ssp_redirect(size_t, confstr, (int __name, char *__buf, size_t __len), \ + (__name, __buf, __len)); +#endif + +__ssp_redirect_raw(char *, getcwd, (char *__buf, size_t __len), + (__buf, __len), __buf != 0, __ssp_bos); + +#if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500) +__ssp_redirect(int, getdomainname, (char *__buf, size_t __len), \ + (__buf, __len)); +#endif + +__ssp_decl(int, getgroups, (int __n, gid_t __buf[])) +{ + __ssp_check(__buf, __n * sizeof(gid_t), __ssp_bos); + return __ssp_real_getgroups (__n, __buf); +} + +#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500 +#if !(defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS)) +__ssp_redirect(int, gethostname, (char *__buf, size_t __len), \ + (__buf, __len)); +#endif +#endif + +__ssp_redirect(int, getlogin_r, (char *__buf, size_t __len), \ + (__buf, __len)); + +#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 500 +__ssp_redirect0(ssize_t, pread, (int __fd, void *__buf, size_t __len, off_t __off), \ + (__fd, __buf, __len, __off)); +#endif + __ssp_redirect0(_READ_WRITE_RETURN_TYPE, read, \ (int __fd, void *__buf, size_t __len), (__fd, __buf, __len)); @@ -44,8 +78,14 @@ __ssp_redirect(ssize_t, readlink, (const char *__restrict __path, \ char *__restrict __buf, size_t __len), (__path, __buf, __len)); #endif -__ssp_redirect_raw(char *, getcwd, (char *__buf, size_t __len), - (__buf, __len), __buf != 0, __ssp_bos); +#if __ATFILE_VISIBLE +__ssp_redirect(ssize_t, readlinkat, \ + (int __dirfd1, const char *__restrict __path, char *__restrict __buf, size_t __len), \ + (__dirfd1, __path, __buf, __len)); +#endif + +__ssp_redirect(int, ttyname_r, (int __fd, char *__buf, size_t __len), \ + (__fd, __buf, __len)); __END_DECLS diff --git a/newlib/libc/ssp/ssp.tex b/newlib/libc/ssp/ssp.tex index b30ecf159..1e0cb6b12 100644 --- a/newlib/libc/ssp/ssp.tex +++ b/newlib/libc/ssp/ssp.tex @@ -43,6 +43,7 @@ fread snprintf vsprintf mbstowcs wcstombs wctomb @exdent @emph{System functions:} -getcwd read readlink +getcwd read ttyname_r +pread readlink @end example