[PATCH] D118692: [llvm-objcopy][COFF] Fix section name encoding

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 1 05:28:47 PST 2022


mstorsjo added inline comments.


================
Comment at: llvm/tools/llvm-objcopy/COFF/Writer.cpp:173
+        // it adds a null termination character
+        snprintf(str, sizeof(S.Header.Name) + 1, "/%d", (int)offset);
+      } else if (offset <= MaxBase64Offset) {
----------------
npmiller wrote:
> mstorsjo wrote:
> > Wouldn't this end up overwriting the first byte following `S.Header.Name`? (It might be benign to do that in practice here, but nevertheless, it would be better to not write outside of the intended struct fields.)
> No because this is no writing to the struct field but to an intermediary string `str`. The correct amount of data is `memcpy`'d into the struct field from `str` a bit further down.
Oh, right, I see! Sorry for the confusion.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118692/new/

https://reviews.llvm.org/D118692



More information about the llvm-commits mailing list