diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-04-27 20:19:05 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-04-27 20:19:05 -0400 |
commit | 48ea8f5470aa6f35244d1b218316705ea88c0259 (patch) | |
tree | b4e9a2d1cc227be96f2c3de815b5b2b4c12e3cb5 /tools | |
parent | 23346f21b277e3aae5e9989e711a11cbe8133a45 (diff) |
perf machine: Pass buffer size to machine__mmap_name
Don't blindly assume that the size of the buffer is enough, use
snprintf.
Cc: Avi Kivity <avi@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Zhang, Yanmin <yanmin_zhang@linux.intel.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/event.c | 4 | ||||
-rw-r--r-- | tools/perf/util/map.c | 10 | ||||
-rw-r--r-- | tools/perf/util/map.h | 2 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 6 |
4 files changed, 11 insertions, 11 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 2f33ca9899bd..7400e5147e13 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -288,7 +288,7 @@ int event__synthesize_kernel_mmap(event__handler_t process, | |||
288 | */ | 288 | */ |
289 | struct process_symbol_args args = { .name = symbol_name, }; | 289 | struct process_symbol_args args = { .name = symbol_name, }; |
290 | 290 | ||
291 | mmap_name = machine__mmap_name(machine, name_buff); | 291 | mmap_name = machine__mmap_name(machine, name_buff, sizeof(name_buff)); |
292 | if (machine__is_host(machine)) { | 292 | if (machine__is_host(machine)) { |
293 | /* | 293 | /* |
294 | * kernel uses PERF_RECORD_MISC_USER for user space maps, | 294 | * kernel uses PERF_RECORD_MISC_USER for user space maps, |
@@ -399,7 +399,7 @@ static int event__process_kernel_mmap(event_t *self, | |||
399 | goto out_problem; | 399 | goto out_problem; |
400 | } | 400 | } |
401 | 401 | ||
402 | machine__mmap_name(machine, kmmap_prefix); | 402 | machine__mmap_name(machine, kmmap_prefix, sizeof(kmmap_prefix)); |
403 | if (machine__is_host(machine)) | 403 | if (machine__is_host(machine)) |
404 | kernel_type = DSO_TYPE_KERNEL; | 404 | kernel_type = DSO_TYPE_KERNEL; |
405 | else | 405 | else |
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index da3d4e826231..ee25ee91504b 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
@@ -629,14 +629,14 @@ void machines__process(struct rb_root *self, machine__process_t process, void *d | |||
629 | } | 629 | } |
630 | } | 630 | } |
631 | 631 | ||
632 | char *machine__mmap_name(struct machine *self, char *buff) | 632 | char *machine__mmap_name(struct machine *self, char *bf, size_t size) |
633 | { | 633 | { |
634 | if (machine__is_host(self)) | 634 | if (machine__is_host(self)) |
635 | sprintf(buff, "[%s]", "kernel.kallsyms"); | 635 | snprintf(bf, size, "[%s]", "kernel.kallsyms"); |
636 | else if (machine__is_default_guest(self)) | 636 | else if (machine__is_default_guest(self)) |
637 | sprintf(buff, "[%s]", "guest.kernel.kallsyms"); | 637 | snprintf(bf, size, "[%s]", "guest.kernel.kallsyms"); |
638 | else | 638 | else |
639 | sprintf(buff, "[%s.%d]", "guest.kernel.kallsyms", self->pid); | 639 | snprintf(bf, size, "[%s.%d]", "guest.kernel.kallsyms", self->pid); |
640 | 640 | ||
641 | return buff; | 641 | return bf; |
642 | } | 642 | } |
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index 4c1c2da704b2..6fabad1fd025 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h | |||
@@ -133,7 +133,7 @@ struct machine *machines__add(struct rb_root *self, pid_t pid, | |||
133 | struct machine *machines__find_host(struct rb_root *self); | 133 | struct machine *machines__find_host(struct rb_root *self); |
134 | struct machine *machines__find(struct rb_root *self, pid_t pid); | 134 | struct machine *machines__find(struct rb_root *self, pid_t pid); |
135 | struct machine *machines__findnew(struct rb_root *self, pid_t pid); | 135 | struct machine *machines__findnew(struct rb_root *self, pid_t pid); |
136 | char *machine__mmap_name(struct machine *self, char *buff); | 136 | char *machine__mmap_name(struct machine *self, char *bf, size_t size); |
137 | 137 | ||
138 | /* | 138 | /* |
139 | * Default guest kernel is defined by parameter --guestkallsyms | 139 | * Default guest kernel is defined by parameter --guestkallsyms |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index dc046368b5cf..c9c0bdd667ac 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -1856,7 +1856,7 @@ static int dso__load_guest_kernel_sym(struct dso *self, struct map *map, | |||
1856 | out_try_fixup: | 1856 | out_try_fixup: |
1857 | if (err > 0) { | 1857 | if (err > 0) { |
1858 | if (kallsyms_filename != NULL) { | 1858 | if (kallsyms_filename != NULL) { |
1859 | machine__mmap_name(machine, path); | 1859 | machine__mmap_name(machine, path, sizeof(path)); |
1860 | dso__set_long_name(self, strdup(path)); | 1860 | dso__set_long_name(self, strdup(path)); |
1861 | } | 1861 | } |
1862 | map__fixup_start(map); | 1862 | map__fixup_start(map); |
@@ -1961,8 +1961,8 @@ struct dso *dso__new_kernel(const char *name) | |||
1961 | static struct dso *dso__new_guest_kernel(struct machine *machine, | 1961 | static struct dso *dso__new_guest_kernel(struct machine *machine, |
1962 | const char *name) | 1962 | const char *name) |
1963 | { | 1963 | { |
1964 | char buff[PATH_MAX]; | 1964 | char bf[PATH_MAX]; |
1965 | struct dso *self = dso__new(name ?: machine__mmap_name(machine, buff)); | 1965 | struct dso *self = dso__new(name ?: machine__mmap_name(machine, bf, sizeof(bf))); |
1966 | 1966 | ||
1967 | if (self != NULL) { | 1967 | if (self != NULL) { |
1968 | dso__set_short_name(self, "[guest.kernel]"); | 1968 | dso__set_short_name(self, "[guest.kernel]"); |