From patchwork Sat Mar 30 13:28:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrice Fontaine X-Patchwork-Id: 1070829 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="A/51sV30"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44WfZb10vZz9sRf for ; Sun, 31 Mar 2019 00:28:52 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id DD29A8445A; Sat, 30 Mar 2019 13:28:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UUxE_6XYuEsH; Sat, 30 Mar 2019 13:28:46 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id E60588445E; Sat, 30 Mar 2019 13:28:45 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 3F0141BF40B for ; Sat, 30 Mar 2019 13:28:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 39AD2228B4 for ; Sat, 30 Mar 2019 13:28:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1kRSWAE5d-7S for ; Sat, 30 Mar 2019 13:28:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by silver.osuosl.org (Postfix) with ESMTPS id 1114522668 for ; Sat, 30 Mar 2019 13:28:43 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id y7so5929516wrn.11 for ; Sat, 30 Mar 2019 06:28:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zh5GcPF0RuoP2nqt0jQTerhtUQxRgvBt3BdE4xSqmI0=; b=A/51sV30+2LUkS50BhU2DIBkQjog5H+HquB9xBaCok337UsIz2x58CaijtuTn97eBw NsyBO/Ii00wFwAbJdTj9h6fNSxPOnXSXcBqqN7utaiwhczd5/4iI8bfSot08xqaCgNP4 VS1VPPtTZDl3yxyjmZlKyKEAvJE02aJOiMEzgQts2CdYQUmT60YGsQm1eaneWukRiTRB fpK5VvffneCYksp0+eHZ04+PtPUR4Fxw9LBRGnxmOFG3IRBXGc7+u5H7/WapyePJfOVg GdApXoMd6CM6ljKqvQmAxRzPtBeqEeM0+So6s+NG/PjqMSAMVdksHX3uKRF81Q26DItP P12w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zh5GcPF0RuoP2nqt0jQTerhtUQxRgvBt3BdE4xSqmI0=; b=Ggy34KQPbHktUcS4zhVAYYMoCXI7XMNivOtCCFNR0DWDx+7XYsqHeO502BcnHFFaqB OVkhbTpTV/pYjOim2vwwUp9zESVYgmU/vOTk/VGeW0hsKJ8t5FaS5RCEIcuxgDiyHddh TZBUAf4ocRNvfDuKwwoTMc52KYT4XGuOPItnVzwtdC/E+HxYGb4pFnjy5hNQqQcQrNbY GDaDhzRwlIjw20Dt6Ahz3cbB546XlLgMNugL18JrvFjaXMrk2N58Wg1roHMvub+P96Iw W9i/1rjHHUvwGO3FMdZge4hDlEBBnJSWFqLFiXd1QqvphjQhHBjNyEMAWpNqo+omhEN1 MNUw== X-Gm-Message-State: APjAAAVmUWRId1THRaSsWe8MZvjpKU0nbqk4rCqSSgAnyCI03N+ztz+S mkRAudSDWxb6vQLr3kuXnK9MJPGg X-Google-Smtp-Source: APXvYqyXnSGNOv1A/68zVqXcNG4ceoKCT4TzOPg63KDdQZVZZUwOJwCD99Fe6LwARvCUqZCRhe9tWg== X-Received: by 2002:adf:ce8f:: with SMTP id r15mr32669417wrn.90.1553952521239; Sat, 30 Mar 2019 06:28:41 -0700 (PDT) Received: from kali.home (lfbn-ren-1-314-196.w2-10.abo.wanadoo.fr. [2.10.15.196]) by smtp.gmail.com with ESMTPSA id a8sm7291288wmf.33.2019.03.30.06.28.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 06:28:40 -0700 (PDT) From: Fabrice Fontaine To: buildroot@buildroot.org Date: Sat, 30 Mar 2019 14:28:30 +0100 Message-Id: <20190330132830.19249-1-fontaine.fabrice@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Buildroot] [PATCH 1/1] package/xenomai: fix build with gcc 8 X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Romain Naour , Fabrice Fontaine , Thomas De Schampheleire Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Patch was wrongly removed in d0dcca4705aaae85ce4ef0dc637b95fd4e81b9b3 Fixes: - http://autobuild.buildroot.org/results/beac5f07c3b56596a6d9d5a1bcf29eb2837c4829 Signed-off-by: Fabrice Fontaine --- ...ated-destination-buffer-with-strncpy.patch | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 package/xenomai/0001-demos-posix-prevent-unterminated-destination-buffer-with-strncpy.patch diff --git a/package/xenomai/0001-demos-posix-prevent-unterminated-destination-buffer-with-strncpy.patch b/package/xenomai/0001-demos-posix-prevent-unterminated-destination-buffer-with-strncpy.patch new file mode 100644 index 0000000000..cb2b1fee48 --- /dev/null +++ b/package/xenomai/0001-demos-posix-prevent-unterminated-destination-buffer-with-strncpy.patch @@ -0,0 +1,91 @@ +From cdc63fe259c70a8a5304aa07087650ebf4ee6b5d Mon Sep 17 00:00:00 2001 +From: Philippe Gerum +Date: Wed, 24 Oct 2018 11:28:49 +0200 +Subject: [PATCH] demos/posix: prevent unterminated destination buffer with + strncpy() + +GCC 8.x introduced -Wstringop-truncation to help detecting likely +unwanted outcomes of strncpy(dst, src, n), such as omitting the NUL +character into the destination buffer whenever n < sizeof(src). + +Fix unsafe strncpy() calls when we do expect a null-terminated +destination buffer. + +Signed-off-by: Philippe Gerum +Signed-off-by: Fabrice Fontaine +[Retrieved from: +https://gitlab.denx.de/Xenomai/xenomai/commit/cdc63fe259c70a8a5304aa07087650ebf4ee6b5d] +--- + demo/posix/cobalt/can-rtt.c | 4 ++-- + demo/posix/cobalt/eth_p_all.c | 3 ++- + demo/posix/cyclictest/cyclictest.c | 4 ++-- + 3 files changed, 6 insertions(+), 5 deletions(-) + +diff --git a/demo/posix/cobalt/can-rtt.c b/demo/posix/cobalt/can-rtt.c +index 61cad05e5..dd212d804 100644 +--- a/demo/posix/cobalt/can-rtt.c ++++ b/demo/posix/cobalt/can-rtt.c +@@ -248,7 +248,7 @@ int main(int argc, char *argv[]) + return -1; + } + +- strncpy(ifr.ifr_name, rxdev, IFNAMSIZ); ++ namecpy(ifr.ifr_name, rxdev); + printf("RX rxsock=%d, ifr_name=%s\n", rxsock, ifr.ifr_name); + + if (ioctl(rxsock, SIOCGIFINDEX, &ifr) < 0) { +@@ -282,7 +282,7 @@ int main(int argc, char *argv[]) + goto failure1; + } + +- strncpy(ifr.ifr_name, txdev, IFNAMSIZ); ++ namecpy(ifr.ifr_name, txdev); + printf("TX txsock=%d, ifr_name=%s\n", txsock, ifr.ifr_name); + + if (ioctl(txsock, SIOCGIFINDEX, &ifr) < 0) { +diff --git a/demo/posix/cobalt/eth_p_all.c b/demo/posix/cobalt/eth_p_all.c +index 6ac12ab3e..91aef9fbd 100644 +--- a/demo/posix/cobalt/eth_p_all.c ++++ b/demo/posix/cobalt/eth_p_all.c +@@ -40,6 +40,7 @@ + #include + #include + #include ++#include + + char buffer[10*1024]; + int sock; +@@ -72,7 +73,7 @@ int main(int argc, char *argv[]) + if (argc > 1) { + struct ifreq ifr; + +- strncpy(ifr.ifr_name, argv[1], IFNAMSIZ); ++ namecpy(ifr.ifr_name, argv[1]); + if (ioctl(sock, SIOCGIFINDEX, &ifr) < 0) { + perror("cannot get interface index"); + close(sock); +diff --git a/demo/posix/cyclictest/cyclictest.c b/demo/posix/cyclictest/cyclictest.c +index ebe5461db..76983bd02 100644 +--- a/demo/posix/cyclictest/cyclictest.c ++++ b/demo/posix/cyclictest/cyclictest.c +@@ -1353,7 +1353,7 @@ static void process_options (int argc, char *argv[], int max_cpus) + case 'F': + case OPT_FIFO: + use_fifo = 1; +- strncpy(fifopath, optarg, strlen(optarg)); ++ strncpy(fifopath, optarg, sizeof(fifopath) - 1); + break; + + case 'H': +@@ -1458,7 +1458,7 @@ static void process_options (int argc, char *argv[], int max_cpus) + case 'T': + case OPT_TRACER: + tracetype = CUSTOM; +- strncpy(tracer, optarg, sizeof(tracer)); ++ strncpy(tracer, optarg, sizeof(tracer) - 1); + break; + case 'u': + case OPT_UNBUFFERED: +-- +2.18.1 +