public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] ubiupdatevol: make the -t parameter work again
@ 2008-12-17 10:15 Sebastian Andrzej Siewior
  2009-01-20 11:25 ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2008-12-17 10:15 UTC (permalink / raw)
  To: linux-mtd

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 <bigeasy@linutronix.de>
---
 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;
 }
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ubiupdatevol: make the -t parameter work again
  2008-12-17 10:15 [PATCH] ubiupdatevol: make the -t parameter work again Sebastian Andrzej Siewior
@ 2009-01-20 11:25 ` Sebastian Andrzej Siewior
  2009-01-20 11:33   ` Artem Bityutskiy
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2009-01-20 11:25 UTC (permalink / raw)
  To: Artem Bityutskiy; +Cc: linux-mtd

ping

* Sebastian Andrzej Siewior | 2008-12-17 11:15:54 [+0100]:

>From bigeasy at linutronix.de  Wed Dec 17 05:15:54 2008
>From: bigeasy at linutronix.de (Sebastian Andrzej Siewior)
>Date: Wed, 17 Dec 2008 11:15:54 +0100
>Subject: [PATCH] ubiupdatevol: make the -t parameter work again
>Message-ID: <20081217101554.GA4999@www.tglx.de>
>
>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 <bigeasy at linutronix.de>
>---
> 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;
> }
>-- 
>1.5.6.5
>

Sebastian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ubiupdatevol: make the -t parameter work again
  2009-01-20 11:25 ` Sebastian Andrzej Siewior
@ 2009-01-20 11:33   ` Artem Bityutskiy
  0 siblings, 0 replies; 3+ messages in thread
From: Artem Bityutskiy @ 2009-01-20 11:33 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior; +Cc: linux-mtd

On Tue, 2009-01-20 at 12:25 +0100, Sebastian Andrzej Siewior wrote:
> ping
> 
> * Sebastian Andrzej Siewior | 2008-12-17 11:15:54 [+0100]:
> 
> >From bigeasy at linutronix.de  Wed Dec 17 05:15:54 2008
> >From: bigeasy at linutronix.de (Sebastian Andrzej Siewior)
> >Date: Wed, 17 Dec 2008 11:15:54 +0100
> >Subject: [PATCH] ubiupdatevol: make the -t parameter work again
> >Message-ID: <20081217101554.GA4999@www.tglx.de>
> >
> >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.

Pushed, thank you.

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-01-20 11:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-17 10:15 [PATCH] ubiupdatevol: make the -t parameter work again Sebastian Andrzej Siewior
2009-01-20 11:25 ` Sebastian Andrzej Siewior
2009-01-20 11:33   ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox