[llvm] [yaml2obj] Apply output size limit to COFF (PR #209695)
Haohai Wen via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 15 01:47:51 PDT 2026
================
@@ -632,10 +612,21 @@ bool yaml2coff(llvm::COFFYAML::Object &Doc, raw_ostream &Out,
ErrHandler("failed to layout COFF file");
return false;
}
- if (!writeCOFF(CP, Out)) {
+
+ // Limit the output size to guard against a runaway YAML description.
+ ContiguousBlobAccumulator CBA(/*BaseOffset=*/0, MaxSize);
+ if (!writeCOFF(CP, CBA)) {
ErrHandler("failed to write COFF file");
return false;
}
+ if (Error E = CBA.takeLimitError()) {
+ consumeError(std::move(E));
+ ErrHandler("the desired output size is greater than permitted. Use the "
+ "--max-size option to change the limit");
----------------
HaohaiWen wrote:
Fixed. 475b3b97e9ef4c67328f775e92516fed561ac091
https://github.com/llvm/llvm-project/pull/209695
More information about the llvm-commits
mailing list