From patchwork Tue Aug 30 09:30:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 112225 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 7B09EB6F8E for ; Tue, 30 Aug 2011 19:30:26 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AF402280C4; Tue, 30 Aug 2011 11:30:24 +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 ehIrWHLEmNAE; Tue, 30 Aug 2011 11:30:24 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 34AA02807E; Tue, 30 Aug 2011 11:30:22 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EFBF3280BC for ; Tue, 30 Aug 2011 11:30:19 +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 JZtvM7bLZc4z for ; Tue, 30 Aug 2011 11:30:17 +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 mail-bw0-f44.google.com (mail-bw0-f44.google.com [209.85.214.44]) by theia.denx.de (Postfix) with ESMTPS id 3729D2807E for ; Tue, 30 Aug 2011 11:30:16 +0200 (CEST) Received: by bkar4 with SMTP id r4so4360317bka.3 for ; Tue, 30 Aug 2011 02:30:16 -0700 (PDT) Received: by 10.204.136.66 with SMTP id q2mr2856703bkt.269.1314696615772; Tue, 30 Aug 2011 02:30:15 -0700 (PDT) Received: from localhost ([178.23.216.97]) by mx.google.com with ESMTPS id j17sm1451165bks.13.2011.08.30.02.30.14 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 30 Aug 2011 02:30:15 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de Date: Tue, 30 Aug 2011 11:30:13 +0200 Message-Id: <1314696613-31095-1-git-send-email-monstr@monstr.eu> X-Mailer: git-send-email 1.5.5.1 Subject: [U-Boot] [PATCH v2] net: Check network device driver name 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 If name is longer than allocated space NAMESIZE mac address is rewritten which show error message like: Error message: Warning: Xlltemac.87000000 MAC addresses don't match: Address in SROM is 30:00:00:00:00:00 Address in environment is 00:0a:35:00:6a:04 NAMESIZE contains Driver name + zero terminated character. Signed-off-by: Michal Simek --- v2: Apply Mike Frysinger version --- net/eth.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/net/eth.c b/net/eth.c index a34fe59..c9b7e85 100644 --- a/net/eth.c +++ b/net/eth.c @@ -224,6 +224,14 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name, int eth_register(struct eth_device *dev) { struct eth_device *d; + + size_t len = strlen(dev->name); + if (len >= NAMESIZE) { + printf("Network driver name is too long (%zu >= %zu): %s\n", + len, NAMESIZE, dev->name); + return -1; + } + if (!eth_devices) { eth_current = eth_devices = dev; eth_current_changed();