From patchwork Thu Jul 14 14:09:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurence Withers X-Patchwork-Id: 104681 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 2133BB6EE8 for ; Fri, 15 Jul 2011 00:09:53 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 313612808C; Thu, 14 Jul 2011 16:09:51 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QBopwu5xkaZS; Thu, 14 Jul 2011 16:09:51 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 17CCB2808D; Thu, 14 Jul 2011 16:09:47 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0E7E92808D for ; Thu, 14 Jul 2011 16:09:45 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3tT83xBKRqj7 for ; Thu, 14 Jul 2011 16:09:44 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from chrysocolla.lwithers.me.uk (chrysocolla.lwithers.me.uk [80.68.94.184]) by theia.denx.de (Postfix) with ESMTPS id 1E2B22808C for ; Thu, 14 Jul 2011 16:09:42 +0200 (CEST) Received: from 4.b.0.2.4.9.e.f.f.f.5.6.f.6.e.1.0.0.0.0.5.a.1.0.0.b.8.0.1.0.0.2.ip6.arpa ([2001:8b0:1a5:0:1e6f:65ff:fe94:20b4] helo=rhodium.platinum.guralp.com) by chrysocolla.lwithers.me.uk with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1QhMbk-0005Qu-Oj; Thu, 14 Jul 2011 14:09:40 +0000 Received: from lwithers by rhodium.platinum.guralp.com with local (Exim 4.72) (envelope-from ) id 1QhMbk-0006Aa-6Z; Thu, 14 Jul 2011 14:09:40 +0000 From: Laurence Withers To: u-boot@lists.denx.de Date: Thu, 14 Jul 2011 14:09:30 +0000 Message-Id: <1310652570-23687-1-git-send-email-lwithers@guralp.com> X-Mailer: git-send-email 1.7.2.5 Cc: Andy Fleming Subject: [U-Boot] [PATCH v2] miiphy: use strncpy() not sprintf() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de In miiphy_register() the new device's name was initialised by passing a string parameter as the format string to sprintf(). As this would cause problems if it ever contained a '%' symbol, switch to using strncpy() instead. Signed-off-by: Laurence Withers Cc: Andy Fleming --- Changes for v2: - Use strncpy() rather than plain strcpy() for extra safety. --- common/miiphyutil.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/common/miiphyutil.c b/common/miiphyutil.c index bcab74e..bc9896e 100644 --- a/common/miiphyutil.c +++ b/common/miiphyutil.c @@ -141,7 +141,8 @@ void miiphy_register(const char *name, /* initalize mii_dev struct fields */ new_dev->read = legacy_miiphy_read; new_dev->write = legacy_miiphy_write; - sprintf(new_dev->name, name); + strncpy(new_dev->name, name, MDIO_NAME_LEN); + new_dev->name[MDIO_NAME_LEN - 1] = 0; ldev->read = read; ldev->write = write; new_dev->priv = ldev;