summaryrefslogtreecommitdiffstats
path: root/applypatch/imgdiff.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2015-09-08 19:57:58 +0200
committerAndroid Git Automerger <android-git-automerger@android.com>2015-09-08 19:57:58 +0200
commit282e5724674e8f2358eef57989bd0ce44ba7d6de (patch)
treeb296a406719d8dd5cf7dd054c33647b3a8aa337a /applypatch/imgdiff.cpp
parentam 1e8e6a83: am cf11a160: am f8c303f9: Merge "move uncrypt from init.rc to uncrypt.rc" (diff)
parentam e5571a0f: am 585a50ce: Merge "imgdiff: fix file descriptor leak" (diff)
downloadandroid_bootable_recovery-282e5724674e8f2358eef57989bd0ce44ba7d6de.tar
android_bootable_recovery-282e5724674e8f2358eef57989bd0ce44ba7d6de.tar.gz
android_bootable_recovery-282e5724674e8f2358eef57989bd0ce44ba7d6de.tar.bz2
android_bootable_recovery-282e5724674e8f2358eef57989bd0ce44ba7d6de.tar.lz
android_bootable_recovery-282e5724674e8f2358eef57989bd0ce44ba7d6de.tar.xz
android_bootable_recovery-282e5724674e8f2358eef57989bd0ce44ba7d6de.tar.zst
android_bootable_recovery-282e5724674e8f2358eef57989bd0ce44ba7d6de.zip
Diffstat (limited to 'applypatch/imgdiff.cpp')
-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) {