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