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

Commit 831b0729 authored by Ryan Mitchell's avatar Ryan Mitchell
Browse files

Add idmap completely parsed assertion

If LoadedIdmap::Load finishes parsing the idmap file but has not
parsed the entire file, then it parsed the file incorrectly. Log
an error if the idmap fails to parse.

Bug: 174676094
Test: libandroidfw_tests
Change-Id: I8ae7ed525715ab907d5813975c1ef5d1260bbd33
parent fb4d09ca
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -326,6 +326,11 @@ std::unique_ptr<const LoadedIdmap> LoadedIdmap::Load(const StringPiece& idmap_pa
    }
  }

  if (data_size != 0) {
    LOG(ERROR) << "idmap parsed with " << data_size << "bytes remaining";
    return {};
  }

  // Can't use make_unique because LoadedIdmap constructor is private.
  return std::unique_ptr<LoadedIdmap>(
      new LoadedIdmap(idmap_path.to_string(), header, data_header, target_entries,