From patchwork Thu Feb 28 08:28:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gang X-Patchwork-Id: 223815 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 3E9772C0040 for ; Thu, 28 Feb 2013 19:29:02 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752785Ab3B1I26 (ORCPT ); Thu, 28 Feb 2013 03:28:58 -0500 Received: from intranet.asianux.com ([58.214.24.6]:31211 "EHLO intranet.asianux.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752474Ab3B1I26 (ORCPT ); Thu, 28 Feb 2013 03:28:58 -0500 Received: by intranet.asianux.com (Postfix, from userid 103) id E919D1840297; Thu, 28 Feb 2013 16:28:56 +0800 (CST) X-Spam-Score: -100.8 X-Spam-Checker-Version: SpamAssassin 3.1.9 (2007-02-13) on intranet.asianux.com X-Spam-Level: X-Spam-Status: No, score=-100.8 required=5.0 tests=AWL,BAYES_00, RATWARE_GECKO_BUILD, TW_CP, USER_IN_WHITELIST autolearn=no version=3.1.9 Received: from [10.1.0.143] (unknown [219.143.36.82]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by intranet.asianux.com (Postfix) with ESMTP id 8F0851840247; Thu, 28 Feb 2013 16:28:54 +0800 (CST) Message-ID: <512F1534.9020404@asianux.com> Date: Thu, 28 Feb 2013 16:28:36 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: venkat.x.venkatsubra@oracle.com, David Miller , rds-devel@oss.oracle.com, netdev Subject: [PATCH] net/rds: using strlcpy instead of strncpy Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org when src strlen is sizeof(ctr.name) - 1, the dest str is not '\0' end. better use strlcpy instead. Signed-off-by: Chen Gang --- net/rds/stats.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/net/rds/stats.c b/net/rds/stats.c index 7be790d..b9ac1df 100644 --- a/net/rds/stats.c +++ b/net/rds/stats.c @@ -86,7 +86,7 @@ void rds_stats_info_copy(struct rds_info_iterator *iter, for (i = 0; i < nr; i++) { BUG_ON(strlen(names[i]) >= sizeof(ctr.name)); - strncpy(ctr.name, names[i], sizeof(ctr.name) - 1); + strlcpy(ctr.name, names[i], sizeof(ctr.name)); ctr.value = values[i]; rds_info_copy(iter, &ctr, sizeof(ctr));