summaryrefslogtreecommitdiffstats
path: root/uncrypt
diff options
context:
space:
mode:
authorSungmin Choi <sungmin.choi@lge.com>2014-12-10 21:57:09 +0900
committerPatrick Tjin <pattjin@google.com>2014-12-10 21:50:46 -0800
commita72512cd058da7de4cdb667776ed47fad873f12c (patch)
tree727566ab86238522e57ef942507bc0e4036216a4 /uncrypt
parentf59b994264b2e8ffe179e2405cda81811f8a9db1 (diff)
downloadbootable_recovery-a72512cd058da7de4cdb667776ed47fad873f12c.zip
bootable_recovery-a72512cd058da7de4cdb667776ed47fad873f12c.tar.gz
bootable_recovery-a72512cd058da7de4cdb667776ed47fad873f12c.tar.bz2
Add O_CREAT option for open
Factory reset fails if there is no file, for example, RECOVERY_COMMAND_FILE_TMP. So create file as adding O_CREAT option if it does not exist. error log: --------- beginning of crash 12-10 02:35:17.190 3059 3059 F libc : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x30 in tid 3059 (uncrypt) 12-10 02:35:17.296 766 1528 W NativeCrashListener: Couldn't find ProcessRecord for pid 3059 12-10 02:35:17.296 191 191 I DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 12-10 02:35:17.296 191 191 E DEBUG : AM write failure (32 / Broken pipe) 12-10 02:35:17.296 191 191 I DEBUG : Build fingerprint: 'Android/aosp_hammerhead/hammerhead:5.1/LMP/hopemini12052127:userdebug/test-keys' 12-10 02:35:17.296 191 191 I DEBUG : Revision: '10' 12-10 02:35:17.297 191 191 I DEBUG : ABI: 'arm' 12-10 02:35:17.297 191 191 I DEBUG : pid: 3059, tid: 3059, name: uncrypt >>> /system/bin/uncrypt <<< 12-10 02:35:17.297 191 191 I DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x30 12-10 02:35:17.302 191 191 I DEBUG : r0 00000001 r1 be94b690 r2 fffffe90 r3 b6fdbf7c 12-10 02:35:17.302 191 191 I DEBUG : r4 00000000 r5 00000000 r6 b6fd8ca4 r7 be94b67c 12-10 02:35:17.302 191 191 I DEBUG : r8 00000000 r9 ffffffff sl b6ff582b fp be94b68d 12-10 02:35:17.302 191 191 I DEBUG : ip b6fcfd08 sp be94b648 lr b6f98fe5 pc b6f98fe4 cpsr 20070030 12-10 02:35:17.303 191 191 I DEBUG : 12-10 02:35:17.303 191 191 I DEBUG : backtrace: 12-10 02:35:17.303 191 191 I DEBUG : #00 pc 00032fe4 /system/lib/libc.so (fputs+29) 12-10 02:35:17.303 191 191 I DEBUG : #01 pc 000016a1 /system/bin/uncrypt 12-10 02:35:17.303 191 191 I DEBUG : #02 pc 0000114b /system/bin/uncrypt 12-10 02:35:17.303 191 191 I DEBUG : #03 pc 00012df5 /system/lib/libc.so (__libc_init+44) 12-10 02:35:17.303 191 191 I DEBUG : #04 pc 000013cc /system/bin/uncrypt 12-10 02:35:17.325 191 191 I DEBUG : 12-10 02:35:17.325 191 191 I DEBUG : Tombstone written to: /data/tombstones/tombstone_00 Bug: 18709330 Change-Id: Ib5dccdd366e829049938a188ea5f98d9e4e282db
Diffstat (limited to 'uncrypt')
-rw-r--r--uncrypt/uncrypt.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/uncrypt/uncrypt.c b/uncrypt/uncrypt.c
index 361c804..7fb0989 100644
--- a/uncrypt/uncrypt.c
+++ b/uncrypt/uncrypt.c
@@ -164,7 +164,11 @@ char* parse_recovery_command_file()
if (f == NULL) {
return NULL;
}
- int fd = open(RECOVERY_COMMAND_FILE_TMP, O_WRONLY | O_SYNC);
+ int fd = open(RECOVERY_COMMAND_FILE_TMP, O_WRONLY | O_CREAT | O_SYNC, S_IRUSR | S_IWUSR);
+ if (fd < 0) {
+ ALOGE("failed to open %s\n", RECOVERY_COMMAND_FILE_TMP);
+ return NULL;
+ }
FILE* fo = fdopen(fd, "w");
while (fgets(temp, sizeof(temp), f)) {
@@ -192,7 +196,11 @@ int produce_block_map(const char* path, const char* map_file, const char* blk_de
struct stat sb;
int ret;
- int mapfd = open(map_file, O_WRONLY | O_SYNC);
+ int mapfd = open(map_file, O_WRONLY | O_CREAT | O_SYNC, S_IRUSR | S_IWUSR);
+ if (mapfd < 0) {
+ ALOGE("failed to open %s\n", map_file);
+ return -1;
+ }
FILE* mapf = fdopen(mapfd, "w");
ret = stat(path, &sb);