Loading tools/aapt2/BigBuffer.h +1 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #ifndef AAPT_BIG_BUFFER_H #define AAPT_BIG_BUFFER_H #include <cassert> #include <cstring> #include <memory> #include <vector> Loading tools/aapt2/BinaryResourceParser.cpp +17 −13 Original line number Diff line number Diff line Loading @@ -157,8 +157,12 @@ bool BinaryResourceParser::getSymbol(const void* data, ResourceNameRef* outSymbo return false; } if (reinterpret_cast<uintptr_t>(data) < reinterpret_cast<uintptr_t>(mData)) { return false; } // We only support 32 bit offsets right now. const ptrdiff_t offset = reinterpret_cast<uintptr_t>(data) - const uintptr_t offset = reinterpret_cast<uintptr_t>(data) - reinterpret_cast<uintptr_t>(mData); if (offset > std::numeric_limits<uint32_t>::max()) { return false; Loading Loading @@ -227,7 +231,7 @@ bool BinaryResourceParser::parseSymbolTable(const ResChunk_header* chunk) { return false; } if (mSymbolPool.setTo(parser.getChunk(), parser.getChunk()->size) != android::NO_ERROR) { if (mSymbolPool.setTo(parser.getChunk(), parser.getChunk()->size) != NO_ERROR) { Logger::error(mSource) << "failed to parse symbol string pool with code: " << mSymbolPool.getError() Loading @@ -252,9 +256,9 @@ bool BinaryResourceParser::parseTable(const ResChunk_header* chunk) { while (ResChunkPullParser::isGoodEvent(parser.next())) { switch (parser.getChunk()->type) { case android::RES_STRING_POOL_TYPE: if (mValuePool.getError() == android::NO_INIT) { if (mValuePool.getError() == NO_INIT) { if (mValuePool.setTo(parser.getChunk(), parser.getChunk()->size) != android::NO_ERROR) { NO_ERROR) { Logger::error(mSource) << "failed to parse value string pool with code: " << mValuePool.getError() Loading @@ -281,7 +285,7 @@ bool BinaryResourceParser::parseTable(const ResChunk_header* chunk) { case RES_TABLE_SOURCE_POOL_TYPE: { if (mSourcePool.setTo(getChunkData(*parser.getChunk()), getChunkDataLen(*parser.getChunk())) != android::NO_ERROR) { getChunkDataLen(*parser.getChunk())) != NO_ERROR) { Logger::error(mSource) << "failed to parse source pool with code: " << mSourcePool.getError() Loading Loading @@ -319,7 +323,7 @@ bool BinaryResourceParser::parseTable(const ResChunk_header* chunk) { } bool BinaryResourceParser::parsePackage(const ResChunk_header* chunk) { if (mValuePool.getError() != android::NO_ERROR) { if (mValuePool.getError() != NO_ERROR) { Logger::error(mSource) << "no value string pool for ResTable." << std::endl; Loading Loading @@ -356,9 +360,9 @@ bool BinaryResourceParser::parsePackage(const ResChunk_header* chunk) { while (ResChunkPullParser::isGoodEvent(parser.next())) { switch (parser.getChunk()->type) { case android::RES_STRING_POOL_TYPE: if (mTypePool.getError() == android::NO_INIT) { if (mTypePool.getError() == NO_INIT) { if (mTypePool.setTo(parser.getChunk(), parser.getChunk()->size) != android::NO_ERROR) { NO_ERROR) { Logger::error(mSource) << "failed to parse type string pool with code " << mTypePool.getError() Loading @@ -366,9 +370,9 @@ bool BinaryResourceParser::parsePackage(const ResChunk_header* chunk) { << std::endl; return false; } } else if (mKeyPool.getError() == android::NO_INIT) { } else if (mKeyPool.getError() == NO_INIT) { if (mKeyPool.setTo(parser.getChunk(), parser.getChunk()->size) != android::NO_ERROR) { NO_ERROR) { Logger::error(mSource) << "failed to parse key string pool with code " << mKeyPool.getError() Loading Loading @@ -429,7 +433,7 @@ bool BinaryResourceParser::parsePackage(const ResChunk_header* chunk) { } bool BinaryResourceParser::parseTypeSpec(const ResChunk_header* chunk) { if (mTypePool.getError() != android::NO_ERROR) { if (mTypePool.getError() != NO_ERROR) { Logger::error(mSource) << "no type string pool available for ResTable_typeSpec." << std::endl; Loading @@ -456,14 +460,14 @@ bool BinaryResourceParser::parseTypeSpec(const ResChunk_header* chunk) { } bool BinaryResourceParser::parseType(const ResChunk_header* chunk) { if (mTypePool.getError() != android::NO_ERROR) { if (mTypePool.getError() != NO_ERROR) { Logger::error(mSource) << "no type string pool available for ResTable_typeSpec." << std::endl; return false; } if (mKeyPool.getError() != android::NO_ERROR) { if (mKeyPool.getError() != NO_ERROR) { Logger::error(mSource) << "no key string pool available for ResTable_type." << std::endl; Loading tools/aapt2/Files.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,11 @@ #include <string> #include <sys/stat.h> #ifdef HAVE_MS_C_RUNTIME // Windows includes. #include <direct.h> #endif namespace aapt { FileType getFileType(const StringPiece& path) { Loading @@ -43,10 +48,14 @@ FileType getFileType(const StringPiece& path) { return FileType::kBlockDev; } else if (S_ISFIFO(sb.st_mode)) { return FileType::kFifo; #if defined(S_ISLNK) } else if (S_ISLNK(sb.st_mode)) { return FileType::kSymlink; #endif #if defined(S_ISSOCK) } else if (S_ISSOCK(sb.st_mode)) { return FileType::kSocket; #endif } else { return FileType::kUnknown; } Loading tools/aapt2/Files.h +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include "Source.h" #include "StringPiece.h" #include <cassert> #include <string> #include <vector> Loading tools/aapt2/JavaClassGenerator.cpp +11 −8 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "ResourceValues.h" #include "StringPiece.h" #include <algorithm> #include <ostream> #include <set> #include <sstream> Loading Loading @@ -87,10 +88,11 @@ bool JavaClassGenerator::generateType(std::ostream& out, const ResourceTableType assert(id.isValid()); if (!isValidSymbol(entry->name)) { mError = (std::stringstream() << "invalid symbol name '" std::stringstream err; err << "invalid symbol name '" << StringPiece16(entry->name) << "'").str(); << "'"; mError = err.str(); return false; } Loading Loading @@ -164,10 +166,11 @@ bool JavaClassGenerator::generate(std::ostream& out) { for (const auto& entry : type->entries) { assert(!entry->values.empty()); if (!isValidSymbol(entry->name)) { mError = (std::stringstream() << "invalid symbol name '" std::stringstream err; err << "invalid symbol name '" << StringPiece16(entry->name) << "'").str(); << "'"; mError = err.str(); return false; } entry->values.front().value->accept(*this, GenArgs{ out, *entry }); Loading Loading
tools/aapt2/BigBuffer.h +1 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #ifndef AAPT_BIG_BUFFER_H #define AAPT_BIG_BUFFER_H #include <cassert> #include <cstring> #include <memory> #include <vector> Loading
tools/aapt2/BinaryResourceParser.cpp +17 −13 Original line number Diff line number Diff line Loading @@ -157,8 +157,12 @@ bool BinaryResourceParser::getSymbol(const void* data, ResourceNameRef* outSymbo return false; } if (reinterpret_cast<uintptr_t>(data) < reinterpret_cast<uintptr_t>(mData)) { return false; } // We only support 32 bit offsets right now. const ptrdiff_t offset = reinterpret_cast<uintptr_t>(data) - const uintptr_t offset = reinterpret_cast<uintptr_t>(data) - reinterpret_cast<uintptr_t>(mData); if (offset > std::numeric_limits<uint32_t>::max()) { return false; Loading Loading @@ -227,7 +231,7 @@ bool BinaryResourceParser::parseSymbolTable(const ResChunk_header* chunk) { return false; } if (mSymbolPool.setTo(parser.getChunk(), parser.getChunk()->size) != android::NO_ERROR) { if (mSymbolPool.setTo(parser.getChunk(), parser.getChunk()->size) != NO_ERROR) { Logger::error(mSource) << "failed to parse symbol string pool with code: " << mSymbolPool.getError() Loading @@ -252,9 +256,9 @@ bool BinaryResourceParser::parseTable(const ResChunk_header* chunk) { while (ResChunkPullParser::isGoodEvent(parser.next())) { switch (parser.getChunk()->type) { case android::RES_STRING_POOL_TYPE: if (mValuePool.getError() == android::NO_INIT) { if (mValuePool.getError() == NO_INIT) { if (mValuePool.setTo(parser.getChunk(), parser.getChunk()->size) != android::NO_ERROR) { NO_ERROR) { Logger::error(mSource) << "failed to parse value string pool with code: " << mValuePool.getError() Loading @@ -281,7 +285,7 @@ bool BinaryResourceParser::parseTable(const ResChunk_header* chunk) { case RES_TABLE_SOURCE_POOL_TYPE: { if (mSourcePool.setTo(getChunkData(*parser.getChunk()), getChunkDataLen(*parser.getChunk())) != android::NO_ERROR) { getChunkDataLen(*parser.getChunk())) != NO_ERROR) { Logger::error(mSource) << "failed to parse source pool with code: " << mSourcePool.getError() Loading Loading @@ -319,7 +323,7 @@ bool BinaryResourceParser::parseTable(const ResChunk_header* chunk) { } bool BinaryResourceParser::parsePackage(const ResChunk_header* chunk) { if (mValuePool.getError() != android::NO_ERROR) { if (mValuePool.getError() != NO_ERROR) { Logger::error(mSource) << "no value string pool for ResTable." << std::endl; Loading Loading @@ -356,9 +360,9 @@ bool BinaryResourceParser::parsePackage(const ResChunk_header* chunk) { while (ResChunkPullParser::isGoodEvent(parser.next())) { switch (parser.getChunk()->type) { case android::RES_STRING_POOL_TYPE: if (mTypePool.getError() == android::NO_INIT) { if (mTypePool.getError() == NO_INIT) { if (mTypePool.setTo(parser.getChunk(), parser.getChunk()->size) != android::NO_ERROR) { NO_ERROR) { Logger::error(mSource) << "failed to parse type string pool with code " << mTypePool.getError() Loading @@ -366,9 +370,9 @@ bool BinaryResourceParser::parsePackage(const ResChunk_header* chunk) { << std::endl; return false; } } else if (mKeyPool.getError() == android::NO_INIT) { } else if (mKeyPool.getError() == NO_INIT) { if (mKeyPool.setTo(parser.getChunk(), parser.getChunk()->size) != android::NO_ERROR) { NO_ERROR) { Logger::error(mSource) << "failed to parse key string pool with code " << mKeyPool.getError() Loading Loading @@ -429,7 +433,7 @@ bool BinaryResourceParser::parsePackage(const ResChunk_header* chunk) { } bool BinaryResourceParser::parseTypeSpec(const ResChunk_header* chunk) { if (mTypePool.getError() != android::NO_ERROR) { if (mTypePool.getError() != NO_ERROR) { Logger::error(mSource) << "no type string pool available for ResTable_typeSpec." << std::endl; Loading @@ -456,14 +460,14 @@ bool BinaryResourceParser::parseTypeSpec(const ResChunk_header* chunk) { } bool BinaryResourceParser::parseType(const ResChunk_header* chunk) { if (mTypePool.getError() != android::NO_ERROR) { if (mTypePool.getError() != NO_ERROR) { Logger::error(mSource) << "no type string pool available for ResTable_typeSpec." << std::endl; return false; } if (mKeyPool.getError() != android::NO_ERROR) { if (mKeyPool.getError() != NO_ERROR) { Logger::error(mSource) << "no key string pool available for ResTable_type." << std::endl; Loading
tools/aapt2/Files.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,11 @@ #include <string> #include <sys/stat.h> #ifdef HAVE_MS_C_RUNTIME // Windows includes. #include <direct.h> #endif namespace aapt { FileType getFileType(const StringPiece& path) { Loading @@ -43,10 +48,14 @@ FileType getFileType(const StringPiece& path) { return FileType::kBlockDev; } else if (S_ISFIFO(sb.st_mode)) { return FileType::kFifo; #if defined(S_ISLNK) } else if (S_ISLNK(sb.st_mode)) { return FileType::kSymlink; #endif #if defined(S_ISSOCK) } else if (S_ISSOCK(sb.st_mode)) { return FileType::kSocket; #endif } else { return FileType::kUnknown; } Loading
tools/aapt2/Files.h +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include "Source.h" #include "StringPiece.h" #include <cassert> #include <string> #include <vector> Loading
tools/aapt2/JavaClassGenerator.cpp +11 −8 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "ResourceValues.h" #include "StringPiece.h" #include <algorithm> #include <ostream> #include <set> #include <sstream> Loading Loading @@ -87,10 +88,11 @@ bool JavaClassGenerator::generateType(std::ostream& out, const ResourceTableType assert(id.isValid()); if (!isValidSymbol(entry->name)) { mError = (std::stringstream() << "invalid symbol name '" std::stringstream err; err << "invalid symbol name '" << StringPiece16(entry->name) << "'").str(); << "'"; mError = err.str(); return false; } Loading Loading @@ -164,10 +166,11 @@ bool JavaClassGenerator::generate(std::ostream& out) { for (const auto& entry : type->entries) { assert(!entry->values.empty()); if (!isValidSymbol(entry->name)) { mError = (std::stringstream() << "invalid symbol name '" std::stringstream err; err << "invalid symbol name '" << StringPiece16(entry->name) << "'").str(); << "'"; mError = err.str(); return false; } entry->values.front().value->accept(*this, GenArgs{ out, *entry }); Loading