Skip to content

Commit

Permalink
"Fix" vencode
Browse files Browse the repository at this point in the history
Summary:
Increase buffer size. Use the redzone correctly - the buffer needs to be the full size.

A real fix should change the `encode` methods to use a `vector` or `deque` or similar for easy access as well as growing storage. Or an inspection of all callsites shows that pushing the caller's `vector` through may be acceptable.

Reviewed By: thezhangwei

Differential Revision: D47955944

fbshipit-source-id: 22580d0332907fd758b23c5b068f123daa3fa539
  • Loading branch information
agampe authored and facebook-github-bot committed Aug 1, 2023
1 parent 7662a9a commit a99e1b8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libredex/DexAnnotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,11 @@ void DexEncodedValue::encode(DexOutputIdx* dodx, uint8_t*& encdata) {
void DexEncodedValue::vencode(DexOutputIdx* dodx, std::vector<uint8_t>& bytes) {
// Relatively large buffer as Kotlin metadata annotations may be huge.
constexpr size_t kRedZone = 1024;
constexpr size_t kBufferSize = 8192 - kRedZone;
constexpr size_t kBufferSize = 16384;
uint8_t buffer[kBufferSize];
uint8_t* pend = buffer;
encode(dodx, pend);
always_assert_log((size_t)(pend - buffer) <= kBufferSize,
always_assert_log((size_t)(pend - buffer) <= kBufferSize - kRedZone,
"DexEncodedValue::vencode overflow, size %d: %s",
(int)(pend - buffer), show().c_str());
for (uint8_t* p = buffer; p < pend; p++) {
Expand Down

0 comments on commit a99e1b8

Please sign in to comment.