From patchwork Wed Dec 17 10:15:54 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 14449 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 84BE9DDF13 for ; Wed, 17 Dec 2008 21:18:19 +1100 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux)) id 1LCtRi-0003Us-JX; Wed, 17 Dec 2008 10:16:02 +0000 Received: from www.tglx.de ([62.245.132.106]) by bombadil.infradead.org with esmtps (Exim 4.68 #1 (Red Hat Linux)) id 1LCtRg-0003FO-Ka for linux-mtd@lists.infradead.org; Wed, 17 Dec 2008 10:16:00 +0000 Received: from www.tglx.de (www.tglx.de [127.0.0.1]) by www.tglx.de (8.13.8/8.13.8/TGLX-2007100201) with ESMTP id mBHAFsdH005347 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 17 Dec 2008 11:15:54 +0100 Received: (from bigeasy@localhost) by www.tglx.de (8.13.8/8.13.8/Submit) id mBHAFsfo005346 for linux-mtd@lists.infradead.org; Wed, 17 Dec 2008 11:15:54 +0100 Date: Wed, 17 Dec 2008 11:15:54 +0100 From: Sebastian Andrzej Siewior To: linux-mtd@lists.infradead.org Subject: [PATCH] ubiupdatevol: make the -t parameter work again Message-ID: <20081217101554.GA4999@www.tglx.de> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.4.2.2i X-Key-Id: 97C4700B X-Key-Fingerprint: 09E2 D1F3 9A3A FF13 C3D3 961C 0688 1C1E 97C4 700B X-Virus-Scanned: ClamAV 0.93.2/8770/Wed Dec 17 01:38:25 2008 on www.tglx.de X-Virus-Status: Clean X-Spam-Status: No, score=-1.4 required=5.0 tests=ALL_TRUSTED, AWL autolearn=ham version=3.2.4 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on www.tglx.de X-Spam-Score: 0.0 (/) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The execution of |./ubiupdatevol /dev/ubi0 -t will fail because 'argv[optind + 1]' is undefined and the later executed 'strcmp(args.img, "-")' will segfault. So I can hack around and supply a dummy image or fix it that way. Signed-off-by: Sebastian Andrzej Siewior --- ubi-utils/new-utils/src/ubiupdatevol.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ubi-utils/new-utils/src/ubiupdatevol.c b/ubi-utils/new-utils/src/ubiupdatevol.c index 5eeaa3c..c83731c 100644 --- a/ubi-utils/new-utils/src/ubiupdatevol.c +++ b/ubi-utils/new-utils/src/ubiupdatevol.c @@ -157,10 +157,15 @@ static int parse_opt(int argc, char * const argv[]) args.node = argv[optind]; args.img = argv[optind + 1]; - if (strcmp(args.img, "-") == 0) - args.use_stdin = 1; - if (args.use_stdin && !args.size) - return errmsg("file size must be specified if input is stdin"); + if (args.img && args.truncate) + return errmsg("You can't truncate and specify an image (use -h for help)"); + + if (args.img && !args.truncate) { + if (strcmp(args.img, "-") == 0) + args.use_stdin = 1; + if (args.use_stdin && !args.size) + return errmsg("file size must be specified if input is stdin"); + } return 0; }