summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/common.c5
-rw-r--r--src/idevicerestore.c4
2 files changed, 8 insertions, 1 deletions
diff --git a/src/common.c b/src/common.c
index d4b7c8d..79dc123 100644
--- a/src/common.c
+++ b/src/common.c
@@ -527,7 +527,7 @@ void get_user_input(char *buf, int maxlen, int secure)
int len = 0;
int c;
- while ((c = my_getch())) {
+ while ((c = my_getch()) > 0) {
if ((c == '\r') || (c == '\n')) {
break;
} else if (isprint(c)) {
@@ -541,6 +541,9 @@ void get_user_input(char *buf, int maxlen, int secure)
}
}
}
+ if (c < 0) {
+ len = 0;
+ }
fputs("\n", stdout);
buf[len] = 0;
}
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index f3e9160..ca6f232 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -371,6 +371,10 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
fflush(stdout);
fflush(stdin);
get_user_input(input, 63, 0);
+ if (*input == '\0') {
+ plist_free(signed_fws);
+ return -1;
+ }
unsigned long selected = strtoul(input, NULL, 10);
if (selected == 0 || selected > count) {
printf("Invalid input value. Must be in range: 1..%d\n", count);