[PATCH] D41270: Fix buffer overrun in WindowsResourceCOFFWriter::writeSymbolTable()

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 14 20:14:13 PST 2017


pcc added inline comments.


================
Comment at: llvm/lib/Object/WindowsResource.cpp:564
     char RelocationName[9];
-    sprintf(RelocationName, "$R%06X", DataOffsets[i]);
+    sprintf(RelocationName, "$R%06X", DataOffsets[i] & 0xffffff);
     Symbol = reinterpret_cast<coff_symbol16 *>(BufferStart + CurrentOffset);
----------------
ruiu wrote:
> There seems to be a small chance that this line could create duplicate names, and if two symbols have the same name, something strange could happen. As we discussed, I think it is better to use `i` instead of `DataOffsets[i]` to generate a naem.
But these are static symbols, right? Do we need to give them unique names?

Also, if they only exist for the purpose of relocations, do we even need symbols at all? Can we make each of the relocations relative to the section symbol and store the data offset in the section data?


https://reviews.llvm.org/D41270





More information about the llvm-commits mailing list