From 0adf09b3705c54733e46ace3b6cf08b78533729e Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Mon, 1 Oct 2018 18:35:46 -0700 Subject: [PATCH] linker: fix invalid zip file handling The argument to CloseArchive has type ZipArchiveHandle, but we're passing it a ZipArchiveHandle*. The compiler doesn't detect the type mismatch because ZipArchiveHandle is a typedef for void*. Remove a duplicate close() call: The fourth argument to OpenArchiveFd is "bool assume_ownership = true". Even if the function fails, ownership of the fd is still transferred to a ZipArchive object that's deleted when this code calls CloseArchive. AFAIK, this code path is rarely or never hit. Bug: none Test: manual (eventually, 'linker64 /system!/foo') Change-Id: I95d79809b6e118fb3c39c7b98b8055c8e324db1a --- linker/linker.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/linker/linker.cpp b/linker/linker.cpp index e1fe50f60..277b82382 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -918,8 +918,7 @@ bool ZipArchiveCache::get_or_open(const char* zip_path, ZipArchiveHandle* handle if (OpenArchiveFd(fd, "", handle) != 0) { // invalid zip-file (?) - CloseArchive(handle); - close(fd); + CloseArchive(*handle); return false; }