Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e63d0747 authored by Josh Gao's avatar Josh Gao Committed by android-build-merger
Browse files

Merge "libziparchive: encode type in fdsan owner tag." am: 3da42a6c am: fbb06043

am: 49708763

Change-Id: Id4527f6b5e2686d09be5cb5bcc33d3a47a9cc950
parents ad8ca51f 49708763
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -184,6 +184,13 @@ static int32_t AddToHash(ZipStringOffset* hash_table, const uint64_t hash_table_
  return 0;
}

#if defined(__BIONIC__)
uint64_t GetOwnerTag(const ZipArchive* archive) {
  return android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_ZIPARCHIVE,
                                        reinterpret_cast<uint64_t>(archive));
}
#endif

ZipArchive::ZipArchive(const int fd, bool assume_ownership)
    : mapped_zip(fd),
      close_file(assume_ownership),
@@ -195,7 +202,7 @@ ZipArchive::ZipArchive(const int fd, bool assume_ownership)
      hash_table(nullptr) {
#if defined(__BIONIC__)
  if (assume_ownership) {
    android_fdsan_exchange_owner_tag(fd, 0, reinterpret_cast<uint64_t>(this));
    android_fdsan_exchange_owner_tag(fd, 0, GetOwnerTag(this));
  }
#endif
}
@@ -213,7 +220,7 @@ ZipArchive::ZipArchive(void* address, size_t length)
ZipArchive::~ZipArchive() {
  if (close_file && mapped_zip.GetFileDescriptor() >= 0) {
#if defined(__BIONIC__)
    android_fdsan_close_with_tag(mapped_zip.GetFileDescriptor(), reinterpret_cast<uint64_t>(this));
    android_fdsan_close_with_tag(mapped_zip.GetFileDescriptor(), GetOwnerTag(this));
#else
    close(mapped_zip.GetFileDescriptor());
#endif