[all-commits] [llvm/llvm-project] 67e0f4: [dfsan] Make sprintf interceptor compatible with g...

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed Jan 17 17:14:42 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 67e0f410ff2dbac83602357619a7c931518afc73
      https://github.com/llvm/llvm-project/commit/67e0f410ff2dbac83602357619a7c931518afc73
  Author: Fangrui Song <i at maskray.me>
  Date:   2024-01-17 (Wed, 17 Jan 2024)

  Changed paths:
    M compiler-rt/lib/dfsan/dfsan_custom.cpp
    M compiler-rt/test/dfsan/custom.cpp
    M compiler-rt/test/dfsan/release_shadow_space.c

  Log Message:
  -----------
  [dfsan] Make sprintf interceptor compatible with glibc 2.37+ and musl (#78363)

snprintf interceptors call `format_buffer` with `size==~0ul`, which
may eventually lead to `snprintf(s, n, "Hello world!")` where `s+n`
wraps around. Since glibc 2.37 (https://sourceware.org/PR30441), the
snprintf call does not write the last char. musl snprintf returns -1
with EOVERFLOW when `n > INT_MAX`.

Change `size` to INT_MAX to work with glibc 2.37+ and musl.
snprintf interceptors are not changed. It's user responsibility to not
cause a compatibility issue with libc implementations.

Fix #60678




More information about the All-commits mailing list