From 34d65037e9c033a3c7f202649e29efce4c289a9e Mon Sep 17 00:00:00 2001 From: Songchun Fan Date: Mon, 27 Jul 2020 09:45:33 -0700 Subject: [PATCH] [incremental/adb] fix signature size check Should check signature block size, not file size Test: manual BUG: 157077910 Change-Id: I6f03af58532b3c518c447f6e7407ebfc0ba37b44 --- adb/client/incremental.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adb/client/incremental.cpp b/adb/client/incremental.cpp index 3033059d0..60735f8c5 100644 --- a/adb/client/incremental.cpp +++ b/adb/client/incremental.cpp @@ -55,9 +55,10 @@ static std::pair> read_signature(Size file_size, return {}; } - std::vector invalid_signature; + auto [signature, tree_size] = read_id_sig_headers(fd); - if (st.st_size > kMaxSignatureSize) { + std::vector 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> 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,