Skip to contentSkip to conversation

ubiupdatevol: make the -t parameter work again

PATCH In review Sebastian Andrzej Siewior 3 participants 3 messages Dec 17, 2008 – Jan 20, 2009 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ubiupdatevol: make the -t parameter work again

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.

---
 ubi-utils/new-utils/src/ubiupdatevol.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
ubi-utils/new-utils/src/ubiupdatevol.c +9 -4
index 5eeaa3c..c83731c 100644
@@ -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;
 }
Signature · 1 line
1.5.6.5
#1 lore raw

ping

Quoted 44 lines · * 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: <[email protected]>

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(-)
ubi-utils/new-utils/src/ubiupdatevol.c +9 -4
index 5eeaa3c..c83731c 100644
@@ -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;
 }
Signature · 1 line
1.5.6.5

Sebastian

#2 lore raw
Quoted 15 lines · Sebastian Andrzej Siewior

ping

Quoted 11 lines · * 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: <[email protected]>

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.

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)