From patchwork Thu Jun 7 17:19:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Sakoman X-Patchwork-Id: 163652 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 F3E61B6FAC for ; Fri, 8 Jun 2012 03:19:38 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 93A04281BA; Thu, 7 Jun 2012 19:19:37 +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 b1wtk73S1xmV; Thu, 7 Jun 2012 19:19:37 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ADC15281E5; Thu, 7 Jun 2012 19:19:35 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 36DE6281E5 for ; Thu, 7 Jun 2012 19:19:33 +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 Pwny7d4KiIX9 for ; Thu, 7 Jun 2012 19:19:31 +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-pb0-f44.google.com (mail-pb0-f44.google.com [209.85.160.44]) by theia.denx.de (Postfix) with ESMTPS id 1B9D2281BA for ; Thu, 7 Jun 2012 19:19:30 +0200 (CEST) Received: by pbcwy7 with SMTP id wy7so1262517pbc.3 for ; Thu, 07 Jun 2012 10:19:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=pbDuw6vP2i61dIg9abfYzcg95hUOmPY5JSUbZFcJws8=; b=fDXApeMhvHBirTM1nMlr/41B12K8QTIPO20KwTOE5ggmSBlki8JEREna/YTiVI3eh8 D/Oy8KG8pkE1RNyU3HQIrcpZmpZETHh3renjB0itRFaswRxJZymsbCGhezHwjafM+i/2 bE7mn3BvIcB6mutuL+/mXS0X4NsyZvYGFwsFjApVPnGBbYjvWhoz1i9XbAON1EsXWXEm S/2nPxQxV+LERAvVyGlGKifytAn5Xkim33OxLFC308fWdCXcvZpgS/1SKxUMx5VvOFrZ J34a2jiVOQzrEd18hjfQpcIAqLXpW3y/fQFrR4WqkXJ3TXaAPfiu4pxrdqs5IwEG4tTu kugw== Received: by 10.68.216.2 with SMTP id om2mr11704752pbc.26.1339089568355; Thu, 07 Jun 2012 10:19:28 -0700 (PDT) Received: from quadra (static-74-41-60-154.dsl1.pco.ca.frontiernet.net. [74.41.60.154]) by mx.google.com with ESMTPS id tz10sm1174026pbc.64.2012.06.07.10.19.25 (version=SSLv3 cipher=OTHER); Thu, 07 Jun 2012 10:19:26 -0700 (PDT) From: Steve Sakoman To: u-boot@lists.denx.de Date: Thu, 7 Jun 2012 10:19:18 -0700 Message-Id: <1339089558-22806-1-git-send-email-steve@sakoman.com> X-Mailer: git-send-email 1.7.1 X-Gm-Message-State: ALoCoQndQXkqpuC9WE2Ftj5HhYjDcfD1vGE1hhWz+svlmhVjHOJBTycatxQE/Jp5vTi4aP9WZOvy Cc: Scott Wood , Steve Sakoman Subject: [U-Boot] [PATCH] cmd_nand: fix crashing bug in nand read/write X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 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 Commit 418396e212b59bf907dbccad997ff50f7eb61b16 introduced a bug that causes nand read and nand write to crash in strcmp due to a null pointer. Root cause is that strchr(cmd, '.') returns a null pointer when the input string does not contain a '.' The strcmp function does not check for null pointers, resulting in a crash. Signed-off-by: Steve Sakoman --- common/cmd_nand.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/common/cmd_nand.c b/common/cmd_nand.c index fa44295..a91ccf4 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -617,7 +617,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) s = strchr(cmd, '.'); - if (!strcmp(s, ".raw")) { + if (s && !strcmp(s, ".raw")) { raw = 1; if (arg_off(argv[3], &dev, &off, &size))