From patchwork Mon Jul 8 07:06:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Holger Brunck X-Patchwork-Id: 257467 X-Patchwork-Delegate: trini@ti.com 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 732CF2C007E for ; Mon, 8 Jul 2013 17:07:26 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 67A8C4A047; Mon, 8 Jul 2013 09:07: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 TGY6tg-+XnQn; Mon, 8 Jul 2013 09:07:24 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 546724A08D; Mon, 8 Jul 2013 09:07:23 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 79A6A4A08D for ; Mon, 8 Jul 2013 09:07:21 +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 wN6fhc55P9u2 for ; Mon, 8 Jul 2013 09:07:16 +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-de.keymile.com (mail-de.keymile.com [195.8.104.250]) by theia.denx.de (Postfix) with ESMTPS id 49E194A047 for ; Mon, 8 Jul 2013 09:07:10 +0200 (CEST) Received: from frodo.de.keymile.net ([10.9.1.54]:39355 helo=mailrelay.de.keymile.net) by mail-de.keymile.com with esmtp (Exim 4.76) (envelope-from ) id 1Uw5XH-0005yj-0M; Mon, 08 Jul 2013 09:06:59 +0200 Received: from pc005093.de.keymile.net.de.keymile.net.de.keymile.net (pc005093.de.keymile.net.de.keymile.net.de.keymile.net [172.30.2.67]) by mailrelay.de.keymile.net (8.12.2/8.12.2) with ESMTP id r6874qnV008291; Mon, 8 Jul 2013 09:04:52 +0200 (MEST) From: Holger Brunck To: u-boot@lists.denx.de Date: Mon, 8 Jul 2013 09:06:49 +0200 Message-Id: <1373267209-4668-1-git-send-email-holger.brunck@keymile.com> X-Mailer: git-send-email 1.8.0.1 In-Reply-To: <1372926586-14495-1-git-send-email-holger.brunck@keymile.com> References: <1372926586-14495-1-git-send-email-holger.brunck@keymile.com> Cc: Holger Brunck Subject: [U-Boot] [PATCH v2] cramfs: fix bug for wrong filename comparison 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 "cramfsload uImage_1" succeeds even though the actual file is named "uImage". Fix file name comparison when one name is the prefix of the other. Signed-off-by: Holger Brunck cc: Wolfgang Denk cc: Albert ARIBAUD --- If we have the following entry in cramfs: => cramfsls -rw-r--r-- 1922689 uImage cramfsload would also succeed if we try to do: => cramfsload uImage_1 CRAMFS load complete: 1922689 bytes loaded to 0x100000 The old code succeeds if the begin of the filename we search matches with a filename stored in cramfs. But the searched file may have additional characters and is therfore not the file we are looking for. fs/cramfs/cramfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/cramfs/cramfs.c b/fs/cramfs/cramfs.c index 910955d..e578a1e 100644 --- a/fs/cramfs/cramfs.c +++ b/fs/cramfs/cramfs.c @@ -126,7 +126,8 @@ static unsigned long cramfs_resolve (unsigned long begin, unsigned long offset, namelen--; } - if (!strncmp (filename, name, namelen)) { + if (!strncmp(filename, name, namelen) && + (namelen == strlen(filename))) { char *p = strtok (NULL, "/"); if (raw && (p == NULL || *p == '\0'))