• A
    perf script: Fix invalid read of directory entry after closedir() · 27486a85
    Andreas Gerstmayr 提交于
    closedir(lang_dir) frees the memory of script_dirent->d_name, which
    gets accessed in the next line in a call to scnprintf().
    
    Valgrind report:
    
      Invalid read of size 1
      ==413557==    at 0x483CBE6: strlen (vg_replace_strmem.c:461)
      ==413557==    by 0x4DD45FD: __vfprintf_internal (vfprintf-internal.c:1688)
      ==413557==    by 0x4DE6679: __vsnprintf_internal (vsnprintf.c:114)
      ==413557==    by 0x53A037: vsnprintf (stdio2.h:80)
      ==413557==    by 0x53A037: scnprintf (vsprintf.c:21)
      ==413557==    by 0x435202: get_script_path (builtin-script.c:3223)
      ==413557==  Address 0x52e7313 is 1,139 bytes inside a block of size 32,816 free'd
      ==413557==    at 0x483AA0C: free (vg_replace_malloc.c:540)
      ==413557==    by 0x4E303C0: closedir (closedir.c:50)
      ==413557==    by 0x4351DC: get_script_path (builtin-script.c:3222)
    Signed-off-by: NAndreas Gerstmayr <agerstmayr@redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: http://lore.kernel.org/lkml/20200402124337.419456-1-agerstmayr@redhat.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
    27486a85
builtin-script.c 103.9 KB