From patchwork Thu Jun 20 10:49:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Hongjiang X-Patchwork-Id: 252874 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B00052C0040 for ; Thu, 20 Jun 2013 20:52:58 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757572Ab3FTKws (ORCPT ); Thu, 20 Jun 2013 06:52:48 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:45787 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754919Ab3FTKwr (ORCPT ); Thu, 20 Jun 2013 06:52:47 -0400 Received: from 172.24.2.119 (EHLO szxeml208-edg.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id BDP15154; Thu, 20 Jun 2013 18:52:36 +0800 (CST) Received: from SZXEML461-HUB.china.huawei.com (10.82.67.204) by szxeml208-edg.china.huawei.com (172.24.2.57) with Microsoft SMTP Server (TLS) id 14.1.323.7; Thu, 20 Jun 2013 18:50:30 +0800 Received: from localhost (10.135.72.200) by szxeml461-hub.china.huawei.com (10.82.67.204) with Microsoft SMTP Server id 14.1.323.7; Thu, 20 Jun 2013 18:50:24 +0800 From: Zhao Hongjiang To: CC: , , , , , Zhao Hongjiang Subject: [PATCH 5/5] net: bluetooth: using strlcpy instead of strncpy Date: Thu, 20 Jun 2013 18:49:45 +0800 Message-ID: <1371725385-11540-5-git-send-email-zhaohongjiang@huawei.com> X-Mailer: git-send-email 1.8.0.msysgit.0 In-Reply-To: <1371725385-11540-1-git-send-email-zhaohongjiang@huawei.com> References: <1371725385-11540-1-git-send-email-zhaohongjiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.135.72.200] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org for NUL terminated string, need alway set '\0' in the end. Signed-off-by: Zhao Hongjiang --- net/bluetooth/hidp/core.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 940f5ac..828be45 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -85,7 +85,7 @@ static void hidp_copy_session(struct hidp_session *session, struct hidp_conninfo ci->product = session->input->id.product; ci->version = session->input->id.version; if (session->input->name) - strncpy(ci->name, session->input->name, 128); + strlcpy(ci->name, session->input->name, sizeof(ci->name)); else strncpy(ci->name, "HID Boot Device", 128); } @@ -94,7 +94,7 @@ static void hidp_copy_session(struct hidp_session *session, struct hidp_conninfo ci->vendor = session->hid->vendor; ci->product = session->hid->product; ci->version = session->hid->version; - strncpy(ci->name, session->hid->name, 128); + strlcpy(ci->name, session->hid->name, sizeof(ci->name)); } }