summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2010-07-08 15:38:38 +0200
committerGravatar Martin Szulecki2010-07-08 15:38:38 +0200
commit89436938ba55bdac2162970b37608666a68a1bb7 (patch)
tree1b156ba8df23cf5d02e4effd30b688fb4dfd4d92
parentaf07bf36689bb07a6b862deb69c0391717c73a51 (diff)
downloadidevicerestore-89436938ba55bdac2162970b37608666a68a1bb7.tar.gz
idevicerestore-89436938ba55bdac2162970b37608666a68a1bb7.tar.bz2
Fix segfault and handling of cli arguments
-rw-r--r--src/idevicerestore.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index 38e765d..37577b0 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -47,7 +47,7 @@ static struct option longopts[] = {
};
void usage(int argc, char* argv[]) {
- char *name = strrchr(argv[0], '/');
+ char* name = strrchr(argv[0], '/');
printf("Usage: %s [OPTIONS] FILE\n", (name ? name + 1 : argv[0]));
printf("Restore/upgrade IPSW firmware FILE to an iPhone/iPod Touch.\n");
printf(" -u, --uuid UUID\ttarget specific device by its 40-digit device UUID\n");
@@ -78,7 +78,7 @@ int main(int argc, char* argv[]) {
switch (opt) {
case 'h':
usage(argc, argv);
- break;
+ return 0;
case 'd':
client->flags &= FLAG_DEBUG;
@@ -106,10 +106,10 @@ int main(int argc, char* argv[]) {
}
}
- argc -= optind;
- argv += optind;
+ if ((argc-optind) == 1) {
+ argc -= optind;
+ argv += optind;
- if (argc == 1) {
ipsw = argv[0];
} else {
usage(argc, argv);