[incremental/adb] fix signature size check

Should check signature block size, not file size

Test: manual
BUG: 157077910
Change-Id: I6f03af58532b3c518c447f6e7407ebfc0ba37b44
This commit is contained in:
Songchun Fan 2020-07-27 09:45:33 -07:00
parent bf95cc25e3
commit 34d65037e9
1 changed files with 3 additions and 3 deletions

View File

@ -55,9 +55,10 @@ static std::pair<unique_fd, std::vector<char>> read_signature(Size file_size,
return {};
}
std::vector<char> invalid_signature;
auto [signature, tree_size] = read_id_sig_headers(fd);
if (st.st_size > kMaxSignatureSize) {
std::vector<char> invalid_signature;
if (signature.size() > kMaxSignatureSize) {
if (!silent) {
fprintf(stderr, "Signature is too long. Max allowed is %d. Abort.\n",
kMaxSignatureSize);
@ -65,7 +66,6 @@ static std::pair<unique_fd, std::vector<char>> read_signature(Size file_size,
return {std::move(fd), std::move(invalid_signature)};
}
auto [signature, tree_size] = read_id_sig_headers(fd);
if (auto expected = verity_tree_size_for_file(file_size); tree_size != expected) {
if (!silent) {
fprintf(stderr,