[all-commits] [llvm/llvm-project] c7bd64: [libFuzzer] Use octal instead of hex escape sequen...

Hans via All-commits all-commits at lists.llvm.org
Mon Oct 4 02:34:13 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c7bd6435993ffbe0fbd1a06c2ba6fb55575edbe1
      https://github.com/llvm/llvm-project/commit/c7bd6435993ffbe0fbd1a06c2ba6fb55575edbe1
  Author: Hans Wennborg <hans at chromium.org>
  Date:   2021-10-04 (Mon, 04 Oct 2021)

  Changed paths:
    M compiler-rt/lib/fuzzer/FuzzerIO.cpp
    M compiler-rt/lib/fuzzer/FuzzerIO.h
    M compiler-rt/lib/fuzzer/FuzzerUtil.cpp
    M compiler-rt/lib/fuzzer/tests/FuzzerUnittest.cpp

  Log Message:
  -----------
  [libFuzzer] Use octal instead of hex escape sequences in PrintASCII

Previously, PrintASCII would print the string "\ta" as "\x09a". However,
in C/C++ those strings are not the same: the trailing 'a' is part of the
escape sequence, which means it's equivalent to "\x9a". This is an
annoying quirk of the standard. (See
https://eel.is/c++draft/lex.ccon#nt:hexadecimal-escape-sequence)

To fix this, output three-digit octal escape sequences instead. Since
octal escapes are limited to max three digits, this avoids the problem
of subsequent characters unintentionally becoming part of the escape
sequence.

Dictionary files still use the non-C-compatible hex escapes, but I
believe we can't change the format since it comes from AFL, and
libfuzzer never writes such files, it only has to read them, so they're
not affected by this change.

Differential revision: https://reviews.llvm.org/D110920




More information about the All-commits mailing list