Check the size of the strings in the StringPool before flattening.
Test: Tested for normal functionality when string does not exceed
maximum length and tests for detection of string that is too lonhg for
UTF8i
Bug: b/74176037
Change-Id: Ic71d3671a069e7012e8ca107e79e071499eebbf6
diff --git a/tools/aapt2/StringPool.h b/tools/aapt2/StringPool.h
index 3c1f3dc..f5b464d 100644
--- a/tools/aapt2/StringPool.h
+++ b/tools/aapt2/StringPool.h
@@ -27,6 +27,7 @@
#include "androidfw/StringPiece.h"
#include "ConfigDescription.h"
+#include "Diagnostics.h"
#include "util/BigBuffer.h"
namespace aapt {
@@ -152,8 +153,8 @@
int ref_;
};
- static bool FlattenUtf8(BigBuffer* out, const StringPool& pool);
- static bool FlattenUtf16(BigBuffer* out, const StringPool& pool);
+ static bool FlattenUtf8(BigBuffer* out, const StringPool& pool, IDiagnostics* diag);
+ static bool FlattenUtf16(BigBuffer* out, const StringPool& pool, IDiagnostics* diag);
StringPool() = default;
StringPool(StringPool&&) = default;
@@ -207,7 +208,7 @@
private:
DISALLOW_COPY_AND_ASSIGN(StringPool);
- static bool Flatten(BigBuffer* out, const StringPool& pool, bool utf8);
+ static bool Flatten(BigBuffer* out, const StringPool& pool, bool utf8, IDiagnostics* diag);
Ref MakeRefImpl(const android::StringPiece& str, const Context& context, bool unique);
void ReAssignIndices();