[llvm] [yaml2obj] Apply output size limit to COFF (PR #209695)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 15 01:22:47 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");
----------------
jh7370 wrote:
I'd add a comment to explain why you're consuming the error and reporting a different one rather than just reporting the returned error (similar to what the ELF version is doing).
https://github.com/llvm/llvm-project/pull/209695
More information about the llvm-commits
mailing list