[llvm-bugs] [Bug 49989] New: Off-by-one error in overwrite path of MutationDispatcher::ApplyDictionaryEntry

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 16 04:58:04 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=49989

            Bug ID: 49989
           Summary: Off-by-one error in overwrite path of
                    MutationDispatcher::ApplyDictionaryEntry
           Product: compiler-rt
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: fuzzer
          Assignee: unassignedbugs at nondot.org
          Reporter: meumertzheim at code-intelligence.com
                CC: llvm-bugs at lists.llvm.org

In the overwrite branch of MutationDispatcher::ApplyDictionaryEntry in
FuzzerMutate.cpp, the index Idx at which W.size() bytes are overwritten with
the word W is chosen uniformly at random in the interval [0, Size - W.size())
(see
https://github.com/llvm/llvm-project/blob/1ede08a290ac70b06df6887a39c1a22ccbfcc09f/compiler-rt/lib/fuzzer/FuzzerMutate.cpp#L198).
This means that Idx + W.size() will always be strictly less than Size, i.e.,
the last byte of the current unit will never be overwritten.

If my assessment is correct, I will gladly submit the trivial patch that fixes
the issue: Rand(Size - W.size()) would have to be replaced with Rand(Size + 1 -
W.size()).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210416/c7eb3a6b/attachment.html>


More information about the llvm-bugs mailing list