Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1506909imm; Fri, 22 Jun 2018 19:09:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIPowynuHH3Ng4UlXqclL1gJW5hmmxEsCYr7OuGnDxgQMkJb1YrT+UQBk2v8S6V+1nevCKa X-Received: by 2002:a62:8917:: with SMTP id v23-v6mr4100512pfd.127.1529719779500; Fri, 22 Jun 2018 19:09:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529719779; cv=none; d=google.com; s=arc-20160816; b=cbU+QEln9UxVc8iT6pBChkNfXUtRHXJmOnzbDWJ6pOPdMzrqvn+PXZNNGUG9JsPvH+ 77toU8iQguxKjWo6bY/JObYjei3yX0z3AU5DIroa6cwOIaHs16jou220Rgiu25CS+L+E IzdlVhs38GCfWH+/RW4yaryRGw4cNb9YJNOSEW/jkVAppKuNdQJB3z8X/20bMJ/kLoUz pO0RZ5mk3uzlWLmbTg3cHuTmG//kIuocMtRBzJcWescDT+pSV0xtSpcXjsr++FVaIjfz akZHicQirGc/FBR+jTJSlzBcBJzq63c70pilJH9yDUsqJ440EONUaGFWm/hfO7tBRV/4 fUyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Fqn2rQQxHfn+5uvFZawePFNkUxNVmG8vEiH2xK/JkQg=; b=M4rbiKOUGSo+cMvbzllJlc6JruJ8RYmzT7Dxw8MiylHHHuPa+b3DdICQuMNosRQR0J d6Am6k7NWHbutfoELNumOPY6BpnS8Ro3G/4BYeA7zlXeaJvhjSi2Qvxwq7ZCEDf3Diqi /D0VplhHByDhLpbyKm+UM0YnVE9bAT1Xo2mwG2uC/NcJ81xgiO3+16THj5/pf87JFddz 4aQRPRwEejVDMsGCGWuRC4dozh411RiMrDUWl2cIXKqDRC1Tf7uLWZmx/nCyiT7JZzok VZRK2scpE7TDUJSrlcQiRza/zIzQvHgWiG5JTcaQjkOg7SGWG3hbRT3GSsN37ikFtkWp ZutA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=n8NVHaep; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o10-v6si7324779pgr.175.2018.06.22.19.09.25; Fri, 22 Jun 2018 19:09:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=n8NVHaep; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934643AbeFWCI0 (ORCPT + 99 others); Fri, 22 Jun 2018 22:08:26 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:37158 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934307AbeFWCIX (ORCPT ); Fri, 22 Jun 2018 22:08:23 -0400 Received: by mail-pl0-f66.google.com with SMTP id 31-v6so4266528plc.4; Fri, 22 Jun 2018 19:08:22 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=Fqn2rQQxHfn+5uvFZawePFNkUxNVmG8vEiH2xK/JkQg=; b=n8NVHaepLmMEIoIxzGnPiEmqYMsccFPZ5Vae5hHe58aJPDYcwIR7Aq528wWAiF6LHu Yvjoc2nr8YDoeaXgRj8ING9NdXd7OziaBPxszXg0RuN6At09J/Qzh00xFeNDdrEnW7Pm 4HdtgU0SqbrjRfbxvQBNtRXRWTO0G5cf62C5vZXwnfBFFwwOhTk9QbawDulblb1in3Qt Qe1njd/6+3uL04bEreraEJqMC3ulQAWutsDwpOjqIS0xr042CgYhecxjD1pI5/wrM+Gt oA5+NJ/FXWSV19DeBB3FiBMI7aRwk+Zoi8RJIOjZcpU+oqNcQa9Qljs3F1NkLNFq8U8G IV/Q== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fqn2rQQxHfn+5uvFZawePFNkUxNVmG8vEiH2xK/JkQg=; b=X8v+PubAlNz3SP3ulw9yx1YldVj6zDLDyd7yhZoKGCzLgEE6bKklmqvXVUaqUvWAd/ sL9CDsTUxCQAL6Rg09DaOmdS/ryc2VbGv9vVZY/57ceFF+ZqyhWTpAjkElxm4OYh8gdP l05R83WMommcewycjBtDY+ydvG8Y2tNcWevobWtRllum6vzszB/vyKmyh8TrqgUO+Hum CXIPktEOYpah1iqIULaEi3wLdYtMH9Fcpw9h+Jv9Gcmu+EtLvzMej15YbMuuXlC9EiJy auIwNjIh9TSQ++8V0Zq1oaEzu3Eet6mttBmwV0XLXXVCyvy15UdXxfLRRnwe0XWxvvw/ ka3g== X-Gm-Message-State: APt69E0celhVbJO6Jwweou9/uRWThJqAPh7bGQWkCk0OyjhMIHNBKxO/ SSgO3rA1PZJPaamrzEcSVKU2uQBX X-Received: by 2002:a17:902:bd95:: with SMTP id q21-v6mr3797708pls.237.1529719702336; Fri, 22 Jun 2018 19:08:22 -0700 (PDT) Received: from localhost (g134.124-44-9.ppp.wakwak.ne.jp. [124.44.9.134]) by smtp.gmail.com with ESMTPSA id j10-v6sm19730503pfj.158.2018.06.22.19.08.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Jun 2018 19:08:21 -0700 (PDT) From: Stafford Horne To: LKML Cc: Greg KH , arnd@arndb.de, linux-crypto@vger.kernel.org, Stafford Horne , Herbert Xu , "David S. Miller" Subject: [RFC PATCH 1/2] crypto: Fix -Wstringop-truncation warnings Date: Sat, 23 Jun 2018 11:07:52 +0900 Message-Id: <20180623020753.27266-2-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180623020753.27266-1-shorne@gmail.com> References: <20180623020753.27266-1-shorne@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As of GCC 9.0.0 the build is reporting warnings like: crypto/ablkcipher.c: In function ‘crypto_ablkcipher_report’: crypto/ablkcipher.c:374:2: warning: ‘strncpy’ specified bound 64 equals destination size [-Wstringop-truncation] strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sizeof(rblkcipher.geniv)); ~~~~~~~~~~~~~~~~~~~~~~~~~ This means the strnycpy might create a non null terminated string. Fix this by limiting the size of the string copy to include the null terminator. Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Signed-off-by: Stafford Horne --- crypto/ablkcipher.c | 4 ++-- crypto/blkcipher.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c index d880a4897159..972cd7c879f6 100644 --- a/crypto/ablkcipher.c +++ b/crypto/ablkcipher.c @@ -372,7 +372,7 @@ static int crypto_ablkcipher_report(struct sk_buff *skb, struct crypto_alg *alg) strncpy(rblkcipher.type, "ablkcipher", sizeof(rblkcipher.type)); strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "", - sizeof(rblkcipher.geniv)); + sizeof(rblkcipher.geniv) - 1); rblkcipher.blocksize = alg->cra_blocksize; rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize; @@ -446,7 +446,7 @@ static int crypto_givcipher_report(struct sk_buff *skb, struct crypto_alg *alg) strncpy(rblkcipher.type, "givcipher", sizeof(rblkcipher.type)); strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "", - sizeof(rblkcipher.geniv)); + sizeof(rblkcipher.geniv) - 1); rblkcipher.blocksize = alg->cra_blocksize; rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize; diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c index 01c0d4aa2563..f1644b5cf68c 100644 --- a/crypto/blkcipher.c +++ b/crypto/blkcipher.c @@ -511,7 +511,7 @@ static int crypto_blkcipher_report(struct sk_buff *skb, struct crypto_alg *alg) strncpy(rblkcipher.type, "blkcipher", sizeof(rblkcipher.type)); strncpy(rblkcipher.geniv, alg->cra_blkcipher.geniv ?: "", - sizeof(rblkcipher.geniv)); + sizeof(rblkcipher.geniv) - 1); rblkcipher.blocksize = alg->cra_blocksize; rblkcipher.min_keysize = alg->cra_blkcipher.min_keysize; -- 2.17.0