From patchwork Wed Nov 1 04:52:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaakov Selkowitz X-Patchwork-Id: 117671 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp422179qgn; Tue, 31 Oct 2017 21:53:42 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SSKJ83vpP033d0y6k4q6k38kGYYajwdJjqLtlYZdISCfCgcqr5ldL/IhX+OYAM/Hw+U9BP X-Received: by 10.99.136.198 with SMTP id l189mr4426730pgd.165.1509512022344; Tue, 31 Oct 2017 21:53:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509512022; cv=none; d=google.com; s=arc-20160816; b=CHbHzINZLFQpRmU4SUECmrB7o3/k18aQkvltq7TBANfnPDmgjLjNr1kdracCFdFJGb stX+CNsxDUGVI7gPWAVJIUtH2spcyELCCaDfuqj9DcFYFOrw3QOhthCXqKck5Zf4o2k4 aVI2NJ7i6NJRR+2tQhpxqW5ie3gnR7xjp5mqcSxZRXDrDDJhvxuOl4Q3CkvPvEN8XSPI DmWP26PG4bWNIJVrebkS8IHfQFdDB/0A1NRLBjv3fMOnsxt6Hw9DVD5qIgnhdpYjpUUj 6LdSlh3lV8+sf8ND1CvmIOURtlHFacWDVApFuRcm2S2qZpLWEY8PL2/1CV2iIFE0k7aP Zj3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:dmarc-filter :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=iHJhd2LnV5jPjUkE4dAJwOdArrl12+a+/Z0nCm8/ees=; b=pig6NMrhELZ0AG9QR3BNxSaFgVxZvPdYiSVUMAL9TbVnSFUvTG1xO0FmZLqJONLTn5 pEkZJcTyszkJgoFbnvqjjcGxe46pteGjtGDEqPm6RyzVdWRPucX9op90soW2SUVTFKZt widJAyXTbLzlTTqIkXbZYXnwwh4EnJkJuiQKHorB7gbM5Vvh96w6gckyGeFLc36GwBVe gKd4DapQRsnTXrBEkxETBMrqlTp3JTXvF2DLRcM2FoFV7LMcwTSbkc598S2D5pU10Fnf U7+qe+/SqiBWFmmNGgOR9P5UZ36q4RXB0+XJZpiarZjrADpCFzf/X8tUmecC4Tbm8ywj Q41A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=A2L352at; spf=pass (google.com: domain of newlib-return-15297-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15297-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 w12si3428288pgp.482.2017.10.31.21.53.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Oct 2017 21:53:42 -0700 (PDT) Received-SPF: pass (google.com: domain of newlib-return-15297-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=A2L352at; spf=pass (google.com: domain of newlib-return-15297-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15297-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:in-reply-to :references; q=dns; s=default; b=CuToTmS/nqTtkLYQSZf+HM32gtk9zAg i+PrXY9NphXVN6t5g5AKL5z/oH7dblYHP+KBVoOU0Rq2vraMp/aHrEdP5Q7wTZTS MbOgNU1J1lMrJ4TZeX+GFlLJnwN5plpzCeKit2sW/TE8/NlQjsaJS5WNbpxPK1rw 9ehFAvm5pdX8= 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:in-reply-to :references; s=default; bh=PmjrBnuORgAJvnc2S+pMLT5yIjE=; b=A2L35 2atZVi3MV0wMDNXlR0uKWVjU8Hp9WRGXPSfLxPHfnxPVn7Radk0m/fzKzWlsm6N9 v0N0WPoc9krXPZd/VimYM2bv4//A50Dt+UsT4psvl8w9kcSPyG/FSlt0kNSyBw0C pfzcI+7ZEFr0ixqTQHAhZV8T9UFjUV/isjt6JE= Received: (qmail 106176 invoked by alias); 1 Nov 2017 04:53:04 -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 106095 invoked by uid 89); 1 Nov 2017 04:53:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=1.3 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; Wed, 01 Nov 2017 04:53:02 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ADE3080F75 for ; Wed, 1 Nov 2017 04:53:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ADE3080F75 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=yselkowi@redhat.com Received: from localhost.localdomain (ovpn-125-104.rdu2.redhat.com [10.10.125.104]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3740360605 for ; Wed, 1 Nov 2017 04:53:01 +0000 (UTC) From: Yaakov Selkowitz To: newlib@sourceware.org Subject: [PATCH v1 03/10] ssp: add Object Size Checking for bcopy, bzero Date: Tue, 31 Oct 2017 23:52:39 -0500 Message-Id: <20171101045246.16596-4-yselkowi@redhat.com> In-Reply-To: <20171101045246.16596-1-yselkowi@redhat.com> References: <20171101045246.16596-1-yselkowi@redhat.com> Signed-off-by: Yaakov Selkowitz --- newlib/libc/include/ssp/strings.h | 48 +++++++++++++++++++++++++++++++++++++++ newlib/libc/include/strings.h | 4 ++++ 2 files changed, 52 insertions(+) create mode 100644 newlib/libc/include/ssp/strings.h -- 2.14.3 diff --git a/newlib/libc/include/ssp/strings.h b/newlib/libc/include/ssp/strings.h new file mode 100644 index 000000000..1341a0f88 --- /dev/null +++ b/newlib/libc/include/ssp/strings.h @@ -0,0 +1,48 @@ +/* $NetBSD: strings.h,v 1.3 2008/04/28 20:22:54 martin Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _SSP_STRINGS_H_ +#define _SSP_STRINGS_H_ + +#include + +#if __SSP_FORTIFY_LEVEL > 0 + +#define bcopy(src, dst, len) \ + ((__ssp_bos0(dst) != (size_t)-1) ? \ + __builtin___memmove_chk(dst, src, len, __ssp_bos0(dst)) : \ + __memmove_ichk(dst, src, len)) +#define bzero(dst, len) \ + ((__ssp_bos0(dst) != (size_t)-1) ? \ + __builtin___memset_chk(dst, 0, len, __ssp_bos0(dst)) : \ + __memset_ichk(dst, 0, len)) + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_STRINGS_H_ */ diff --git a/newlib/libc/include/strings.h b/newlib/libc/include/strings.h index 122f2fcd6..f422b6a8c 100644 --- a/newlib/libc/include/strings.h +++ b/newlib/libc/include/strings.h @@ -75,4 +75,8 @@ int strncasecmp_l (const char *, const char *, size_t, locale_t); #endif __END_DECLS +#if _FORTIFY_SOURCE > 0 +#include +#endif + #endif /* _STRINGS_H_ */