Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4535412imm; Mon, 17 Sep 2018 16:03:25 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYe4iSkdg0+ORfDtqMPMhZq4EoKdhyG6Yt4eZSKX87uLWcJG0cGqi8laN5tOm8cpv07Icwq X-Received: by 2002:a62:b604:: with SMTP id j4-v6mr27778260pff.199.1537225405216; Mon, 17 Sep 2018 16:03:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537225405; cv=none; d=google.com; s=arc-20160816; b=s65U9onxDGr1ISrwjilNPv5/teSA56toDCQgzhPHl7LMekiQNAMP5iUee7WC9Wggq/ JIGUi3und23/rE5ZvKBBNyuHOTrFRfCh2eFEn3CZdiVG8G3BV1QeRXKm0FH4oihaS9nY 817FnZxINLsomqn3XIiEuMqD/H2Mqu0rw58Z2NOZk8C4Lh9FzxdCTue0BvhILqCHj2l+ /EAhY8hqvLurcvBFVK1A9lYS4u7PFFhOpbHF1ksKchpDX3D3nS8Cb0qQAQTEzwTYDaxk rytsk0x/taWc3KZW6e+4S0VFYKSmwo2Q+X++AKS0k6ocujwHTmatp6h+UQWBJmg3fcCW 4Yhg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=DnzUz3WrO4YpVQzuVaz5Iuejmco1ImJK7Gm3f1QWAyc=; b=DfocXVO/2vIKDqqXh9xrqEKKvDgUb55ag+0umMW8UFlEGAX3jx13qvYPRJnbx/eG9p z1tLUx50mTSL9I1S6Lcpkqeeod5E4BRBXnx1yVkeAUnYbOh95jQm62n376q8xIF1r5mG AEE1X7dPZtxxkjM+3lxa/KBQzAfadXOLp9vANqRrQLJOMbJwoWGxIhXGZaPc5nhYNjCS Vz8PbZDTrlWNnULUhNmj4mVLnaT10LbJOC7qXF2JQKbTsqJw/SFnVF3ZOJvAO2dnTgTB kntggB7L3hQij0iQ9qLnghnJzwH7QsToT82t6Vw7wGr8houXcv3wehk/9IAtOTYcg7CB FYng== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o126-v6si16586569pfb.20.2018.09.17.16.03.09; Mon, 17 Sep 2018 16:03:25 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730495AbeIREcV (ORCPT + 99 others); Tue, 18 Sep 2018 00:32:21 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48572 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727088AbeIREcT (ORCPT ); Tue, 18 Sep 2018 00:32:19 -0400 Received: from localhost (li1825-44.members.linode.com [172.104.248.44]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 90D10C03; Mon, 17 Sep 2018 23:02:51 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marcel Holtmann , Johan Hedberg , Sasha Levin Subject: [PATCH 4.14 062/126] Bluetooth: hidp: Fix handling of strncpy for hid->name information Date: Tue, 18 Sep 2018 00:41:50 +0200 Message-Id: <20180917211708.469159969@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180917211703.481236999@linuxfoundation.org> References: <20180917211703.481236999@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marcel Holtmann [ Upstream commit b3cadaa485f0c20add1644a5c877b0765b285c0c ] This fixes two issues with setting hid->name information. CC net/bluetooth/hidp/core.o In function ‘hidp_setup_hid’, inlined from ‘hidp_session_dev_init’ at net/bluetooth/hidp/core.c:815:9, inlined from ‘hidp_session_new’ at net/bluetooth/hidp/core.c:953:8, inlined from ‘hidp_connection_add’ at net/bluetooth/hidp/core.c:1366:8: net/bluetooth/hidp/core.c:778:2: warning: ‘strncpy’ output may be truncated copying 127 bytes from a string of length 127 [-Wstringop-truncation] strncpy(hid->name, req->name, sizeof(req->name) - 1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CC net/bluetooth/hidp/core.o net/bluetooth/hidp/core.c: In function ‘hidp_setup_hid’: net/bluetooth/hidp/core.c:778:38: warning: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Wsizeof-pointer-memaccess] strncpy(hid->name, req->name, sizeof(req->name)); ^ Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/hidp/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -775,7 +775,7 @@ static int hidp_setup_hid(struct hidp_se hid->version = req->version; hid->country = req->country; - strncpy(hid->name, req->name, sizeof(req->name) - 1); + strncpy(hid->name, req->name, sizeof(hid->name)); snprintf(hid->phys, sizeof(hid->phys), "%pMR", &l2cap_pi(session->ctrl_sock->sk)->chan->src);