Skip to content

Commit

Permalink
Merge branch 'master' into component-model/parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
dannypsnl committed Nov 2, 2023
2 parents de1b56c + 7d4213b commit dc72f71
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/loader/shared_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ Expect<void> SharedLibrary::load(const AST::AOTSection &AOTSec) noexcept {
const auto Offset = std::get<1>(Section);
const auto Size = std::get<2>(Section);
const auto &Content = std::get<3>(Section);
assuming(Content.size() <= Size);
if (Size > BinarySize || Offset > BinarySize ||
Offset + Size > BinarySize || Content.size() > Size) {
return Unexpect(ErrCode::Value::IntegerTooLarge);
}
std::copy(Content.begin(), Content.end(), Binary + Offset);
switch (std::get<0>(Section)) {
case 1: { // Text
Expand All @@ -116,6 +119,8 @@ Expect<void> SharedLibrary::load(const AST::AOTSection &AOTSec) noexcept {
static_cast<uint32_t>(Size / sizeof(winapi::RUNTIME_FUNCTION_));
break;
#endif
default:
return Unexpect(ErrCode::Value::IntegerTooLarge);
}
}

Expand Down

0 comments on commit dc72f71

Please sign in to comment.