summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2015-09-08 19:40:27 +0200
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-09-08 19:40:27 +0200
commit585a50cecbccf59666dd65e9fc4320eaa3511634 (patch)
tree1b1288f70cf8c534a2c171f39037cf5607480b25
parentMerge "move uncrypt from init.rc to uncrypt.rc" (diff)
parentimgdiff: fix file descriptor leak (diff)
downloadandroid_bootable_recovery-585a50cecbccf59666dd65e9fc4320eaa3511634.tar
android_bootable_recovery-585a50cecbccf59666dd65e9fc4320eaa3511634.tar.gz
android_bootable_recovery-585a50cecbccf59666dd65e9fc4320eaa3511634.tar.bz2
android_bootable_recovery-585a50cecbccf59666dd65e9fc4320eaa3511634.tar.lz
android_bootable_recovery-585a50cecbccf59666dd65e9fc4320eaa3511634.tar.xz
android_bootable_recovery-585a50cecbccf59666dd65e9fc4320eaa3511634.tar.zst
android_bootable_recovery-585a50cecbccf59666dd65e9fc4320eaa3511634.zip
-rw-r--r--applypatch/imgdiff.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/applypatch/imgdiff.cpp b/applypatch/imgdiff.cpp
index 4d83ffb2e..50cabbe6b 100644
--- a/applypatch/imgdiff.cpp
+++ b/applypatch/imgdiff.cpp
@@ -628,7 +628,15 @@ unsigned char* MakePatch(ImageChunk* src, ImageChunk* tgt, size_t* size) {
}
char ptemp[] = "/tmp/imgdiff-patch-XXXXXX";
- mkstemp(ptemp);
+ int fd = mkstemp(ptemp);
+
+ if (fd == -1) {
+ printf("MakePatch failed to create a temporary file: %s\n",
+ strerror(errno));
+ return NULL;
+ }
+ close(fd); // temporary file is created and we don't need its file
+ // descriptor
int r = bsdiff(src->data, src->len, &(src->I), tgt->data, tgt->len, ptemp);
if (r != 0) {