From patchwork Thu Nov 30 03:19:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaakov Selkowitz X-Patchwork-Id: 120068 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp163620qgn; Wed, 29 Nov 2017 19:19:32 -0800 (PST) X-Google-Smtp-Source: AGs4zMbpjNCJsjuhXsDYwkFkBOwA48hoyY1f0JcweLQBdCD2uaA0q+B3NNr3nyAeLrk00wUvtGGQ X-Received: by 10.159.198.4 with SMTP id f4mr1069421plo.331.1512011972304; Wed, 29 Nov 2017 19:19:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512011972; cv=none; d=google.com; s=arc-20160816; b=CizZqV+ZPo1/m82UK9WErI3DNfJXVp3iLWqHGKTfM94KWM3qtQ2W4ZuCnneNBkygsr NKYPUjIm6tAAyRiISuU4hBagsGJ4IrCv9zObHYWWL6lX64AUV1sNBBg0EyxsH/58pRsD mkoWCioUOPG9GgQqt3Phw3bj2Y8AVERfdxSyBNVVO9QGukQnbG79oO3ozTBNZsC6R3iE AJsRgUOXdr5PJfbytF7WZJky9J7gjTckvlW18DAuVeDrgzs/NL/wyEEvIrSGXB6zen5f 5CjzqT/Jp3E2EmAjEXtVKOUKaXCzK2g4rdGZimZEGZYoxlR8MXasNipM1d/trNJqUbjB iBUw== 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=KsND+kjdpybaTGg8+CmpRP1739EbOfp0HucOQjRZqTw=; b=jB/XTeDjDQQqscFRh4g5LRnU2K/qvvlwTvuDjVdUiUa5bXdtL7fdfQYzYAamYJO3U4 p3BujkzG4Av1+WhwXRCfErv5uLOhGgBFuKr7ZY5+bEvq/lc0QgVp+xXJARG/ZqO3YWAX v/SUmGfVXd+zDQBAsOJ2A4F4+S1UFDzShgbU7XK9ApcO46bGtFQdGWdEnM5lMGWwBA05 hu9Mw/OqtN194RgqvVNsD2b3BFTh2kcZO9gtEqwQszrA5kXQ5ZAqVr8J7C5VvbZaUKuP oS0A9kB9NeQPyKqBA2k+/Cqnl91fjOoyHvcAn2p7mYosuckGFCmQU5w7zu8jevfoc0K2 fQng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=UZxCsHOV; spf=pass (google.com: domain of newlib-return-15411-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15411-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 91si2334191ply.98.2017.11.29.19.19.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2017 19:19:32 -0800 (PST) Received-SPF: pass (google.com: domain of newlib-return-15411-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=UZxCsHOV; spf=pass (google.com: domain of newlib-return-15411-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15411-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=GVLWjpNchix6fRiO2pXKmOA7qCEpU8Z0d+pc1syjjsNH3yCTRV6sX 9UpvriVBt2Owxua2MdmdVEGDD/OyLckcb2ZjNUGRtQehzu5/Lgz3wGCgNUUQKmPh YDhwKFu6Eo1oFWBdDO/M1IRH/mfatmll+w2kl+oxT39JW4ltNG+nCY= 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=rQ24u8asBfPkMXGmtW/wKnapSdQ=; b=UZxCsHOVd++oDJpRVdiPWu7xk7Lp mAAv4kYRU3g4W+ZddCPZDI3SgRn+5i2JaxNHCs/dKXyuXL3TjoVd4MZ+5W2Dkgo4 ArdKBGqNsQ7QqTdWwC3kB0wrADoF5+9cvkM99gMreSUtsvtI7i8Z4m6B9obc48Nk 63lvspRy1h8w7+g= Received: (qmail 83026 invoked by alias); 30 Nov 2017 03:19:24 -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 82653 invoked by uid 89); 30 Nov 2017 03:19:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, 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 03:19:22 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5553F76521 for ; Thu, 30 Nov 2017 03:19:21 +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 0FF785D9C7 for ; Thu, 30 Nov 2017 03:19:20 +0000 (UTC) From: Yaakov Selkowitz To: newlib@sourceware.org Subject: [PATCH] ssp: add Object Size Checking for stdlib.h Date: Wed, 29 Nov 2017 21:19:11 -0600 Message-Id: <20171130031911.9900-1-yselkowi@redhat.com> Signed-off-by: Yaakov Selkowitz --- newlib/libc/include/ssp/stdlib.h | 30 ++++++++++++++++++++++++++++++ newlib/libc/include/stdlib.h | 4 ++++ newlib/libc/ssp/ssp.tex | 4 ++++ 3 files changed, 38 insertions(+) create mode 100644 newlib/libc/include/ssp/stdlib.h -- 2.15.0 diff --git a/newlib/libc/include/ssp/stdlib.h b/newlib/libc/include/ssp/stdlib.h new file mode 100644 index 000000000..d5edb6d09 --- /dev/null +++ b/newlib/libc/include/ssp/stdlib.h @@ -0,0 +1,30 @@ +#ifndef _SSP_STDLIB_H_ +#define _SSP_STDLIB_H_ + +#include + +#if __SSP_FORTIFY_LEVEL > 0 +__BEGIN_DECLS + +__ssp_decl(size_t, mbstowcs, (wchar_t *__buf, const char *__src, size_t __n)) +{ + if (__buf != NULL) + __ssp_check(__buf, __n * sizeof(wchar_t), __ssp_bos); + return __ssp_real_mbstowcs (__buf, __src, __n); +} + +__ssp_redirect_raw(size_t, wcstombs, \ + (char *__buf, const wchar_t *__src, size_t __len), \ + (__buf, __src, __len), __buf != NULL, __ssp_bos); + +__ssp_decl(int, wctomb, (char *__buf, wchar_t __wc)) +{ + if (__buf != NULL) + __ssp_check(__buf, MB_CUR_MAX, __ssp_bos); + return __ssp_real_wctomb (__buf, __wc); +} + +__END_DECLS + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_STDLIB_H_ */ diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h index af5bfecf1..c3c591d20 100644 --- a/newlib/libc/include/stdlib.h +++ b/newlib/libc/include/stdlib.h @@ -334,4 +334,8 @@ _Noreturn void _END_STD_C +#if __SSP_FORTIFY_LEVEL > 0 +#include +#endif + #endif /* _STDLIB_H_ */ diff --git a/newlib/libc/ssp/ssp.tex b/newlib/libc/ssp/ssp.tex index f8440bdf9..b30ecf159 100644 --- a/newlib/libc/ssp/ssp.tex +++ b/newlib/libc/ssp/ssp.tex @@ -39,6 +39,10 @@ fgets fread_unlocked sprintf fgets_unlocked gets vsnprintf fread snprintf vsprintf +@exdent @emph{Stdlib functions:} +mbstowcs wcstombs wctomb + @exdent @emph{System functions:} getcwd read readlink + @end example