From patchwork Mon Sep 17 10:58:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cox X-Patchwork-Id: 184372 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 848A42C0098 for ; Mon, 17 Sep 2012 20:40:40 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754596Ab2IQKk1 (ORCPT ); Mon, 17 Sep 2012 06:40:27 -0400 Received: from lxorguk.ukuu.org.uk ([81.2.110.251]:32933 "EHLO lxorguk.ukuu.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754440Ab2IQKkY (ORCPT ); Mon, 17 Sep 2012 06:40:24 -0400 Received: from localhost.localdomain (earthlight.etchedpixels.co.uk [81.2.110.250]) by lxorguk.ukuu.org.uk (8.14.5/8.14.1) with ESMTP id q8HBCtXb000999 for ; Mon, 17 Sep 2012 12:13:01 +0100 From: Alan Cox Subject: [PATCH] ncm: allow for NULL terminations To: netdev@vger.kernel.org Date: Mon, 17 Sep 2012 11:58:55 +0100 Message-ID: <20120917105853.30298.29234.stgit@localhost.localdomain> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Alan Cox The strings are passed to snprintf so must be null terminated. It seems the copy length is incorrectly set. Signed-off-by: Alan Cox --- drivers/net/usb/cdc_ncm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 4cd582a..af8cce7 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -145,10 +145,10 @@ cdc_ncm_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info) { struct usbnet *dev = netdev_priv(net); - strncpy(info->driver, dev->driver_name, sizeof(info->driver)); - strncpy(info->version, DRIVER_VERSION, sizeof(info->version)); + strncpy(info->driver, dev->driver_name, sizeof(info->driver) - 1); + strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1); strncpy(info->fw_version, dev->driver_info->description, - sizeof(info->fw_version)); + sizeof(info->fw_version) - 1); usb_make_path(dev->udev, info->bus_info, sizeof(info->bus_info)); }