[llvm] GOFFObjectFile - use snprintf instead of sprintf (PR #224336)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 17 08:49:50 PDT 2026
================
@@ -897,7 +897,7 @@ void GOFFObjectFile::getRelocationTypeName(
DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
uint64_t RelType = getRelocationType(Rel);
char Buf[16];
- sprintf(Buf, "R_%08lx", RelType);
+ snprintf(Buf, sizeof(Buf), "R_%08lx", RelType);
----------------
fhahn wrote:
It looks like there is another warning:
```
error: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]
900 | snprintf(Buf, sizeof(Buf), "R_%08lx", RelType);
| ~~~~~ ^~~~~~~
| %08llx
```
https://github.com/llvm/llvm-project/pull/224336
More information about the llvm-commits
mailing list