Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp335313imm; Wed, 29 Aug 2018 01:00:00 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZF9sUjtZy1Y9AdHQjpCpGYfnTyvb3ot3aN5dkM4ImplO2lZnpJmIThS4dP1vjErSdR2uUH X-Received: by 2002:a17:902:70cb:: with SMTP id l11-v6mr4792622plt.91.1535529600877; Wed, 29 Aug 2018 01:00:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535529600; cv=none; d=google.com; s=arc-20160816; b=F4YSiozrkMJZKnMf2N/xvervCboUSZnwfEw+yaQ2aSfr8FbgYmabdD9KCO7+6Wam2O Q4lzTadPTb+6XuBw1ugPnMjEdqFRTNLclXLTwnsQIi14PcFdY6VarVc9ZwuJa0HKoRfx C724osFiG6kehfJmXB8vxTtvAF4YAw7q7H1rQvRmAEtTU7EUFCyEStlA0tT3EDoA+V/Q lE2+0HgUisrK9gGt6ptL1ZEvmUzACCUF7Z9/1cspDoyozVID+ZPcDvgukWWkdqVFfoQ3 owo7+OpWNsfFMAG+A9KuxNPDXGvBbO5g87bfSg1QID9BXy3oYvaUvkJTzNZdVh50xZJC vqGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=n5N7rzo2Yz6ToBgcoJnkbL1OiPAx5DE6sy5tATHXNvo=; b=pkwAh3V2UaCdOkfZpsRMeHpVE3GgDA8OABBDCWc0Q46k+4dYgy3LIyhrubv10TchR/ NtJjrkjaNOn6hjU1H31omlzcOdL8dIGEPJbz5wLTyhuF7OIG2VO2qxmdLtSDrTGd0Aeq gVviHHQD8WGjg0GvU8Eol4pH1HIUgZ3rcvY5mJNB4ftazbpjvR+QTF6qHO8Cj8EWW4be GTGsujqNk20ZhNliEipSymxME+kEUIfVYIwRDiwS+ClljME0/RueY2iWCrGpiFJmS1AF FdG2tKQuiTBAVm3vmKUE2E9x7A8BWvlP1veRz2uVCRBasQTPgc2A3TBtalKAxiIuIRaR FDrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZiPY7gA7; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u69-v6si2923152pgd.547.2018.08.29.00.59.45; Wed, 29 Aug 2018 01:00:00 -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=@linaro.org header.s=google header.b=ZiPY7gA7; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728052AbeH2Lxo (ORCPT + 99 others); Wed, 29 Aug 2018 07:53:44 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:46143 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728024AbeH2Lxn (ORCPT ); Wed, 29 Aug 2018 07:53:43 -0400 Received: by mail-lf1-f67.google.com with SMTP id e23-v6so3499830lfc.13 for ; Wed, 29 Aug 2018 00:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n5N7rzo2Yz6ToBgcoJnkbL1OiPAx5DE6sy5tATHXNvo=; b=ZiPY7gA7J17PKABvvERsIGACUT9ycbQk2koUQRQauwaRddCew4S4x2tgVFCDLveVQV v2Ch4TRSQRXa/LbP1LDqpYFCPtmyRpx+27sAp02/nC2WtpJED7y5JAzd7s6poancIZf6 owWVvwdR8w15N7PTsFemdubA4Vd5eQGaUwke4= 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; bh=n5N7rzo2Yz6ToBgcoJnkbL1OiPAx5DE6sy5tATHXNvo=; b=LxT8HtxqsZu0oImAikVkuQc9SBEPJUqN6MqI9FtIhm+sjuHfcWQI6FU/iy7rBd66Dq wmVfDaA70X0+5iIgiSZTEl9rx2hPKAprmCrINX7Qn1kmL0QdTdjPK8GWeHtqDgRhXaSK jkJnhjL53lh7NUdAebnQ7bD/12rQZfDlYUdFOc85TtIm5wDThbDGymtWUnkfX1XWrc4k DbPSG3wH7bbOWAKFWkJF39IMp7BqRv8Ek1SiBMsnhTRv4pdtq89bDTdVolnAf063GKMR ilmRRG5WV/kCvgDxpqjeQuvkfxtx4LrKCva7qykUNqRIVj1RXHacDS6/Xu+Uh1U5l1Pq lo3g== X-Gm-Message-State: APzg51CyWeYWCWZG/dEZs650SbapbMqlOx0/Qkh7m5ufZUDcOBCtxRQQ lhwEAwfxWrDNMkSYB3NgGvu16w== X-Received: by 2002:a19:9355:: with SMTP id v82-v6mr3418687lfd.134.1535529485106; Wed, 29 Aug 2018 00:58:05 -0700 (PDT) Received: from centauri.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j9-v6sm592303ljh.40.2018.08.29.00.58.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 Aug 2018 00:58:04 -0700 (PDT) From: Niklas Cassel To: Andy Gross , David Brown Cc: Niklas Cassel , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 7/9] soc: qcom: wcnss_ctrl: Avoid string overflow Date: Wed, 29 Aug 2018 09:57:21 +0200 Message-Id: <20180829075724.9095-8-niklas.cassel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180829075724.9095-1-niklas.cassel@linaro.org> References: <20180829075724.9095-1-niklas.cassel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'chinfo.name' is used as a NUL-terminated string, but using strncpy() with the length equal to the buffer size may result in lack of the termination: drivers//soc/qcom/wcnss_ctrl.c: In function 'qcom_wcnss_open_channel': drivers//soc/qcom/wcnss_ctrl.c:284:2: warning: 'strncpy' specified bound 32 equals destination size [-Wstringop-truncation] strncpy(chinfo.name, name, sizeof(chinfo.name)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This changes it to use the safer strscpy() instead. Signed-off-by: Niklas Cassel --- drivers/soc/qcom/wcnss_ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soc/qcom/wcnss_ctrl.c b/drivers/soc/qcom/wcnss_ctrl.c index df3ccb30bc2d..373400dd816d 100644 --- a/drivers/soc/qcom/wcnss_ctrl.c +++ b/drivers/soc/qcom/wcnss_ctrl.c @@ -281,7 +281,7 @@ struct rpmsg_endpoint *qcom_wcnss_open_channel(void *wcnss, const char *name, rp struct rpmsg_channel_info chinfo; struct wcnss_ctrl *_wcnss = wcnss; - strncpy(chinfo.name, name, sizeof(chinfo.name)); + strscpy(chinfo.name, name, sizeof(chinfo.name)); chinfo.src = RPMSG_ADDR_ANY; chinfo.dst = RPMSG_ADDR_ANY; -- 2.17.1