Messages in this thread |  | | Date | Sun, 23 May 2021 17:58:10 +0200 | From | Jiri Olsa <> | Subject | Re: [PATCH v6 2/3] perf tests: avoid storing an absolute path in perf binary |
| |
On Fri, May 21, 2021 at 10:27:52AM -0700, Denys Zagorui wrote:
SNIP
> free(cmd); > +out: > + free(pythonpath); > return ret; > } > diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c > index 3bba74e431ed..53f3dbf02f58 100644 > --- a/tools/perf/util/util.c > +++ b/tools/perf/util/util.c > @@ -22,6 +22,7 @@ > #include "cap.h" > #include "strlist.h" > #include "string2.h" > +#include <libgen.h> > > /* > * XXX We need to find a better place for these things... > @@ -388,3 +389,14 @@ char *perf_exe(char *buf, int len) > } > return strcpy(buf, "perf"); > } > + > +char *perf_exe_path(void) > +{ > + char buf[PATH_MAX]; > + char *dname; > + > + perf_exe(buf, PATH_MAX); > + dname = dirname(buf);
I think this is equally bad.. once you get out of perf_exe_path, dname might be screwed
> + > + return dname;
just return strdup(dname) in here?
jirka
|  |