[PATCH] D97663: [llvm-objcopy] Fix crash for binary input files with non-ascii names
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 1 12:37:29 PST 2021
MaskRay added a comment.
C11 says
> The header <ctype.h> declares several functions useful for classifying and mapping characters.198) In all cases the argument is an int, the value of which shall be representable as an unsigned char or shall equal the value of the macro EOF. If the argument has any other value, the behavior is undefined.
The crash problem you described may be similar to https://drewdevault.com/2020/09/25/A-story-of-two-libcs.html
With certain values (negative ones?) glibc may crash.
================
Comment at: llvm/tools/llvm-objcopy/ELF/Object.cpp:1294
std::replace_if(std::begin(SanitizedFilename), std::end(SanitizedFilename),
- [](char C) { return !isalnum(C); }, '_');
+ [](char C) { return !isAlnum(C); }, '_');
Twine Prefix = Twine("_binary_") + SanitizedFilename;
----------------
may need an `unsigned char` cast.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97663/new/
https://reviews.llvm.org/D97663
More information about the llvm-commits
mailing list