[Bug sanitizer/88054] Sanitizer triggers on valid code

marxin at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Nov 16 09:05:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88054

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
The problem looks very similar to:

  3537  #if SANITIZER_INTERCEPT_REALPATH
  3538  INTERCEPTOR(char *, realpath, const char *path, char *resolved_path) {
  3539    void *ctx;
  3540    COMMON_INTERCEPTOR_ENTER(ctx, realpath, path, resolved_path);
  3541    if (path) COMMON_INTERCEPTOR_READ_RANGE(ctx, path, REAL(strlen)(path)
+ 1);
  3542  
  3543    // Workaround a bug in glibc where dlsym(RTLD_NEXT, ...) returns the
oldest
  3544    // version of a versioned symbol. For realpath(), this gives us
something
  3545    // (called __old_realpath) that does not handle NULL in the second
argument.
  3546    // Handle it as part of the interceptor.
  3547    char *allocated_path = nullptr;
  3548    if (!resolved_path)
  3549      allocated_path = resolved_path = (char *)WRAP(malloc)(path_max +
1);
  3550  
  3551    char *res = REAL(realpath)(path, resolved_path);
  3552    if (allocated_path && !res) WRAP(free)(allocated_path);
  3553    if (res) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, res, REAL(strlen)(res) +
1);
  3554    return res;
  3555  }
  3556  #define INIT_REALPATH COMMON_INTERCEPT_FUNCTION(realpath);
  3557  #else
  3558  #define INIT_REALPATH
  3559  #endif


More information about the Gcc-bugs mailing list