[compiler-rt] [dfsan] Add test case for sscanf (PR #94700)

Thurston Dang via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 6 16:43:55 PDT 2024


thurstond wrote:

Relevant code in DFSan's scan_buffer:
```
static int scan_buffer(char *str, size_t size, const char *fmt,
                       dfsan_label *va_labels, dfsan_label *ret_label,
                       dfsan_origin *str_origin, dfsan_origin *ret_origin,
                       va_list ap) {
    ...
    if (*formatter.fmt_cur != '%') {
      // Ordinary character. Consume all the characters until a '%' or the end
      // of the string.
      for (; *(formatter.fmt_cur + 1) && *(formatter.fmt_cur + 1) != '%';
           ++formatter.fmt_cur) {
          // EDITOR'S NOTE: SHOULD THIS CHECK AGAINST THE INPUT STRING?
      }
      retval = formatter.scan();
      dfsan_set_label(0, formatter.str_cur(),
                      formatter.num_written_bytes(retval));
```


https://github.com/llvm/llvm-project/pull/94700


More information about the llvm-commits mailing list