summaryrefslogtreecommitdiffstats
path: root/uncrypt
diff options
context:
space:
mode:
authorMaxim Siniavine <siniavine@google.com>2014-02-13 15:48:53 -0800
committerMaxim Siniavine <siniavine@google.com>2014-02-13 15:53:38 -0800
commite7b288824589b2828d83e1d47f6f12b0bd0fb353 (patch)
tree67a7d0814abc987c9763ce2d162d742c57c2810d /uncrypt
parent707d321a8745accf4660bf77e33f6acb9ce6b779 (diff)
downloadbootable_recovery-e7b288824589b2828d83e1d47f6f12b0bd0fb353.zip
bootable_recovery-e7b288824589b2828d83e1d47f6f12b0bd0fb353.tar.gz
bootable_recovery-e7b288824589b2828d83e1d47f6f12b0bd0fb353.tar.bz2
Fix a crash when going into recovery mode.
When going into recovery mode withoug recovery command file present, uncrypt crashes and the device gets stuck and eventually shuts down. Check that the command file is present before trying to read from it. Change-Id: If0192d597032be0067738e437188d92993ce56f7
Diffstat (limited to 'uncrypt')
-rw-r--r--uncrypt/uncrypt.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/uncrypt/uncrypt.c b/uncrypt/uncrypt.c
index 1f0f59d..7c2d994 100644
--- a/uncrypt/uncrypt.c
+++ b/uncrypt/uncrypt.c
@@ -149,9 +149,14 @@ char* parse_recovery_command_file()
int count = 0;
char temp[1024];
- FILE* fo = fopen(RECOVERY_COMMAND_FILE_TMP, "w");
+
FILE* f = fopen(RECOVERY_COMMAND_FILE, "r");
+ if (f == NULL) {
+ return NULL;
+ }
+ FILE* fo = fopen(RECOVERY_COMMAND_FILE_TMP, "w");
+
while (fgets(temp, sizeof(temp), f)) {
printf("read: %s", temp);
if (strncmp(temp, "--update_package=", strlen("--update_package=")) == 0) {