[sanitizer] Improve scanf interceptor
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Fri, 8 Feb 2013 11:17:20 +0000 (11:17 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Fri, 8 Feb 2013 11:17:20 +0000 (11:17 +0000)
commit87c43537df4bd83b26ebab877721ba24a9ee3685
tree1e2f1a280cb2b8351801840aeca143688460d749
parentacc33666f6218a55421eb6e3ccd116012c23d3d7
[sanitizer] Improve scanf interceptor

This a rewrite of the scanf parser. The new implementation is pretty close to
the spec, with a few shortcuts taken here and there. It is conservative, i.e.
it gives up parsing if it does not understand some part of the format string,
or runs into an ambiguous % spec. It does not handle some rarely used parts of
the spec, like %n$ - for now.

I'm also moving parser call to after the original *scanf function completes,
so that we can find out the store size of %s directive by the use of strlen()
on the target buffer.

llvm-svn: 174704
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_scanf.inc
compiler-rt/lib/sanitizer_common/tests/sanitizer_scanf_interceptor_test.cc