fix (#703)
This commit is contained in:
parent
321bcfeba1
commit
999eaadc16
@ -619,40 +619,45 @@ bool AutoTokensPass::runOnModule(Module &M) {
|
|||||||
|
|
||||||
LLVMContext &Ctx = M.getContext();
|
LLVMContext &Ctx = M.getContext();
|
||||||
|
|
||||||
size_t memlen = 0, count = 0, offset = 0;
|
if (dictionary.size()) {
|
||||||
|
size_t memlen = 0, count = 0, offset = 0;
|
||||||
|
|
||||||
// sort and unique the dictionary
|
// sort and unique the dictionary
|
||||||
std::sort(dictionary.begin(), dictionary.end());
|
std::sort(dictionary.begin(), dictionary.end());
|
||||||
auto last = std::unique(dictionary.begin(), dictionary.end());
|
auto last = std::unique(dictionary.begin(), dictionary.end());
|
||||||
dictionary.erase(last, dictionary.end());
|
dictionary.erase(last, dictionary.end());
|
||||||
|
|
||||||
for (auto token : dictionary) {
|
for (auto token : dictionary) {
|
||||||
memlen += token.length();
|
memlen += token.length();
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto ptrhld = std::unique_ptr<char[]>(new char[memlen + count]);
|
|
||||||
|
|
||||||
count = 0;
|
|
||||||
|
|
||||||
for (auto token : dictionary) {
|
|
||||||
if (offset + token.length() < 0xfffff0 && count < MAX_AUTO_EXTRAS) {
|
|
||||||
// This lenght is guranteed to be < MAX_AUTO_EXTRA
|
|
||||||
ptrhld.get()[offset++] = (uint8_t)token.length();
|
|
||||||
memcpy(ptrhld.get() + offset, token.c_str(), token.length());
|
|
||||||
offset += token.length();
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Type
|
if (count) {
|
||||||
ArrayType *arrayTy = ArrayType::get(IntegerType::get(Ctx, 8), offset);
|
auto ptrhld = std::unique_ptr<char[]>(new char[memlen + count]);
|
||||||
// The actual dict
|
|
||||||
GlobalVariable *dict = new GlobalVariable(
|
count = 0;
|
||||||
M, arrayTy, true, GlobalVariable::ExternalLinkage,
|
|
||||||
ConstantDataArray::get(Ctx, *(new ArrayRef<char>(ptrhld.get(), offset))),
|
for (auto token : dictionary) {
|
||||||
"libafl_dictionary_" + M.getName());
|
if (offset + token.length() < 0xfffff0 && count < MAX_AUTO_EXTRAS) {
|
||||||
dict->setSection("libafl_token");
|
// This lenght is guranteed to be < MAX_AUTO_EXTRA
|
||||||
|
ptrhld.get()[offset++] = (uint8_t)token.length();
|
||||||
|
memcpy(ptrhld.get() + offset, token.c_str(), token.length());
|
||||||
|
offset += token.length();
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type
|
||||||
|
ArrayType *arrayTy = ArrayType::get(IntegerType::get(Ctx, 8), offset);
|
||||||
|
// The actual dict
|
||||||
|
GlobalVariable *dict = new GlobalVariable(
|
||||||
|
M, arrayTy, true, GlobalVariable::ExternalLinkage,
|
||||||
|
ConstantDataArray::get(Ctx,
|
||||||
|
*(new ArrayRef<char>(ptrhld.get(), offset))),
|
||||||
|
"libafl_dictionary_" + M.getName());
|
||||||
|
dict->setSection("libafl_token");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if USE_NEW_PM
|
#if USE_NEW_PM
|
||||||
auto PA = PreservedAnalyses::all();
|
auto PA = PreservedAnalyses::all();
|
||||||
|
@ -11,7 +11,7 @@ cargo fmt
|
|||||||
|
|
||||||
echo "[*] Formatting C(pp) files"
|
echo "[*] Formatting C(pp) files"
|
||||||
# shellcheck disable=SC2046
|
# shellcheck disable=SC2046
|
||||||
clang-format-13 -i --style=file $(find . -type f \( -name '*.cpp' -o -iname '*.hpp' -o -name '*.cc' -o -name '*.cxx' -o -name '*.cc' -o -name '*.h' \) | grep -v '/target/' | grep -v 'libpng-1\.6\.37' | grep -v 'stb_image\.h' | grep -v 'dlmalloc\.c')
|
clang-format -i --style=file $(find . -type f \( -name '*.cpp' -o -iname '*.hpp' -o -name '*.cc' -o -name '*.cxx' -o -name '*.cc' -o -name '*.h' \) | grep -v '/target/' | grep -v 'libpng-1\.6\.37' | grep -v 'stb_image\.h' | grep -v 'dlmalloc\.c')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user