From patchwork Wed Aug 29 07:57:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 10579639 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 557D35A4 for ; Wed, 29 Aug 2018 07:58:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4896C2A941 for ; Wed, 29 Aug 2018 07:58:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A5BE2AA1C; Wed, 29 Aug 2018 07:58:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9F762A941 for ; Wed, 29 Aug 2018 07:58:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728039AbeH2Lxn (ORCPT ); Wed, 29 Aug 2018 07:53:43 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:34322 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728023AbeH2Lxn (ORCPT ); Wed, 29 Aug 2018 07:53:43 -0400 Received: by mail-lf1-f67.google.com with SMTP id g9-v6so3533750lfh.1 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=teRx1s5TrbTphgWbxVR19jMXOdJO5+UIdIdQWCQWyka0vZgP2GsTmAR6OIbKGiEh73 7aTGaf83BwPGmguZbFAxw/o17gG6Veq0J9VmaFLl6JqWid2K4q+KZ7b2YEr1yhp1njTY +5Hbemr0bMO5Af8b6aAKmJNxv/Np7x5lSoDvnvFBqy9MJNEm217F/SjZYdeLtN4v2X/w oj+i+qSn/PBkunkplre0/uZrZGrweIJk9XrRzWVm4WQg5InQh6CanNkfhlIHyC1U4ye9 YxZDzl/ayHoJLSu1Is9Z11pi3SoVvkHB1wuZROY91/5T2VR6PkbEgG1iWyszGZti2krO zbqw== X-Gm-Message-State: APzg51CA3b2RGJh9LBWNtJZJhZ0PoUjqPNHFNZUj2vCA2Q4vzuAQt9WO 8NEYDkX9InnTxudshEZa3fwBMQ== X-Google-Smtp-Source: ANB0VdbK9tycsTbfyUwaPfZv1moWKY93ozWFXTSx9CpQQLzn8fe5WbNKOytMFCEtx+6WYBxhFqvKOw== 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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP '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 Reviewed-by: Bjorn Andersson --- 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;