Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3851561imm; Mon, 25 Jun 2018 05:47:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKNXd0ReOYd0fmU73ID0oRYYgT2pxl2cVomXs5YoDaIJfWu76kfdao/WefLgXumagVXHfl8 X-Received: by 2002:a62:da59:: with SMTP id w25-v6mr12928680pfl.161.1529930828012; Mon, 25 Jun 2018 05:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529930827; cv=none; d=google.com; s=arc-20160816; b=Cpr24FKXSHCnCzVtirWBS6dxKny84zdVH7/fn7habO1EGeAq8mt2HyyqE+PdggOozJ tHdKtDKAHnBkcCy/ayKmcXojBXl+e9TU2xXey01fQjBKS/P0ccwebwWixBt2needaJ9T ZOGfPKaR2YidcgDQ3L2eN98TdJwcKiMBrkz6JxGyLtzHPQxmcCENRRk3lGZ1+etoZjH5 7EorI8hFoQ/jYIePxWdfq96ydN5Kqp5Z0Mufchi+cv+uU0nocQO6bEwhMgzLgPaXKg3e QCiJ0eu5+vBpvvzga6cw1U6R2ZOKVx7EGmN9MtUnIBIFkBb2Q3zvJrXxz5e0Ogmy3lG9 TALw== 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=13yXlQw6OltcuYWZwtKCe7PCGAvW0lIib2/SLO0mGM0=; b=VjcHjsjX82b/cLUcRfHVTzQp8aEFNvuM+Nd46yHsX3Cb7ePaT4yWm1iekOnCPP4cvb dNbEvR1xIshxox5hEaa8B1k0dMn8YBMtsJW4D2KRCLquZmlGH3T4mlyIDk1aYToojvLJ 4HQPsL8kogKXEYi9eZe6s2W8lMXYAJes/lbFx9UMkdhlLV+z1o/bVNiJel/JOnKCL9rn CobEffp3mwqkZbjWlj8y0Q8X4omGnqRdkXIaFJi/ldQ+qapXor8D+TvLnUQTWnutck7z DLDG6gNArwB5m+tZFswhLfy7wcKyXyV08etpx8stj4yCcvYU+2F3K6gG0cC/isXuyeMf 0u1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U0mnyulq; 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 e12-v6si11487359pgt.243.2018.06.25.05.46.53; Mon, 25 Jun 2018 05:47:07 -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=U0mnyulq; 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 S1755445AbeFYMqH (ORCPT + 99 others); Mon, 25 Jun 2018 08:46:07 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:34207 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751529AbeFYMqB (ORCPT ); Mon, 25 Jun 2018 08:46:01 -0400 Received: by mail-pg0-f68.google.com with SMTP id y1-v6so419423pgv.1; Mon, 25 Jun 2018 05:46:00 -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=13yXlQw6OltcuYWZwtKCe7PCGAvW0lIib2/SLO0mGM0=; b=U0mnyulqHv3PSZxri5z6Le1j5uVQkp9VNhIgsxUvyz1ZuaQ21D3w2zQCjqsv8ICL3p a+2oK7ULbZX/kSnWOl7hJWXpzSm0UJLyMBL54Ql91LiKZkYBx8NncvOlF8UWvy3MpI9+ lIbhTOUEsiDguR4Acm6HH06xk2q2jmJJWb79sJRaMMNC+OfR6WSpdDsimIBWDYYXJKgm fWGLvNIN894jlgimHjyMnx5o8U3dQ2kBq3D4Bz+9L7TGRW7YRM9e5Iyx8RbSvIcxAzqN Jj0hudYbrfiZKaMTXlCNEXpdiU9kok+2PRSl8OKtkWq+qWNjusaeXDCnoWdf9tzRoj1n hM5A== 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=13yXlQw6OltcuYWZwtKCe7PCGAvW0lIib2/SLO0mGM0=; b=P9L2sYTFUxag7pmUfXEz8NEfJkDo9yIa/bjYZcyZwH10C/L+e5VWzgurLll4BcMaVB wahl7TCAhS+Fm7cbebj5pUtRKTN1GU3Qu6r2QPwxj2ASYLKA41vSzxiW30uR+RPYm+WI NyssAgg9VOdRcZz7u7RW+WtEVECFxwgpRCNoywxveXdFTL/yl2Cwv2usocvjkgmqEJFu CBZmbPaUt1iqx5JmotA7s9VutLdO/Xxm/91Z2I/Cms3d9c9f7mGzUgmY6mN/Nm+GMrz5 CT+eR0C4cXB4HkqSewTi4OKv0jm0+2DIH7LeEJSM9dPZPesTKJAs2Bv16c/rQvDvCLHx ShQw== X-Gm-Message-State: APt69E2b09F6O69TXIuoYEnHXhwXZO9RVSbJIy0G0wxmO9/9l/Xx7o17 yq/J+AbTovrUWQ8TQ+Q47oWeQWS/Xvk= X-Received: by 2002:a62:930c:: with SMTP id b12-v6mr12901222pfe.193.1529930760215; Mon, 25 Jun 2018 05:46:00 -0700 (PDT) Received: from localhost (g134.124-44-9.ppp.wakwak.ne.jp. [124.44.9.134]) by smtp.gmail.com with ESMTPSA id m12-v6sm2794431pgs.21.2018.06.25.05.45.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Jun 2018 05:45:59 -0700 (PDT) From: Stafford Horne To: LKML Cc: Greg KH , arnd@arndb.de, Eric Biggers , linux-crypto@vger.kernel.org, Stafford Horne , Max Filippov , Nick Desaulniers , Herbert Xu , "David S. Miller" Subject: [PATCH v2 1/2] crypto: Fix -Wstringop-truncation warnings Date: Mon, 25 Jun 2018 21:45:37 +0900 Message-Id: <20180625124538.21051-2-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180625124538.21051-1-shorne@gmail.com> References: <20180625124538.21051-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 explicitly performing '\0' termination. Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Max Filippov Cc: Eric Biggers Cc: Nick Desaulniers Signed-off-by: Stafford Horne --- crypto/ablkcipher.c | 2 ++ crypto/blkcipher.c | 1 + 2 files changed, 3 insertions(+) diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c index d880a4897159..1edb5000d783 100644 --- a/crypto/ablkcipher.c +++ b/crypto/ablkcipher.c @@ -373,6 +373,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)); + rblkcipher.geniv[sizeof(rblkcipher.geniv) - 1] = '\0'; rblkcipher.blocksize = alg->cra_blocksize; rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize; @@ -447,6 +448,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)); + rblkcipher.geniv[sizeof(rblkcipher.geniv) - 1] = '\0'; 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..dd4dcab3766a 100644 --- a/crypto/blkcipher.c +++ b/crypto/blkcipher.c @@ -512,6 +512,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)); + rblkcipher.geniv[sizeof(rblkcipher.geniv) - 1] = '\0'; rblkcipher.blocksize = alg->cra_blocksize; rblkcipher.min_keysize = alg->cra_blkcipher.min_keysize; -- 2.17.0