From 44d94dd2adf27294899e775c70a827ca9237100c Mon Sep 17 00:00:00 2001 From: OGAWA Hirofumi Date: Sun, 6 Dec 2009 20:10:49 +0900 Subject: [PATCH] --- yaml --- r: 175397 b: refs/heads/master c: 7691b1ec2e4a8d4bd88dcf88b29792399ebe1c91 h: refs/heads/master i: 175395: 3fa622264db76b1f27dd306f9bdd7540026d5810 v: v3 --- [refs] | 2 +- trunk/tools/perf/util/header.c | 9 +++++++-- trunk/tools/perf/util/trace-event-parse.c | 2 +- trunk/tools/perf/util/trace-event-read.c | 3 ++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index ca31ce42cfaa..00d5ef5bf2b3 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 180f95e29aa8782c019caa64ede2a28d8ab62564 +refs/heads/master: 7691b1ec2e4a8d4bd88dcf88b29792399ebe1c91 diff --git a/trunk/tools/perf/util/header.c b/trunk/tools/perf/util/header.c index 4805e6dfd23c..08b6759287f5 100644 --- a/trunk/tools/perf/util/header.c +++ b/trunk/tools/perf/util/header.c @@ -187,7 +187,9 @@ static int do_write(int fd, const void *buf, size_t size) static int __dsos__write_buildid_table(struct list_head *head, int fd) { +#define NAME_ALIGN 64 struct dso *pos; + static const char zero_buf[NAME_ALIGN]; list_for_each_entry(pos, head, node) { int err; @@ -197,14 +199,17 @@ static int __dsos__write_buildid_table(struct list_head *head, int fd) if (!pos->has_build_id) continue; len = pos->long_name_len + 1; - len = ALIGN(len, 64); + len = ALIGN(len, NAME_ALIGN); memset(&b, 0, sizeof(b)); memcpy(&b.build_id, pos->build_id, sizeof(pos->build_id)); b.header.size = sizeof(b) + len; err = do_write(fd, &b, sizeof(b)); if (err < 0) return err; - err = do_write(fd, pos->long_name, len); + err = do_write(fd, pos->long_name, pos->long_name_len + 1); + if (err < 0) + return err; + err = do_write(fd, zero_buf, len - pos->long_name_len + 1); if (err < 0) return err; } diff --git a/trunk/tools/perf/util/trace-event-parse.c b/trunk/tools/perf/util/trace-event-parse.c index 0302405aa2ca..6ffe9d63d85d 100644 --- a/trunk/tools/perf/util/trace-event-parse.c +++ b/trunk/tools/perf/util/trace-event-parse.c @@ -177,7 +177,7 @@ void parse_proc_kallsyms(char *file, unsigned int size __unused) func_count++; } - func_list = malloc_or_die(sizeof(*func_list) * func_count + 1); + func_list = malloc_or_die(sizeof(*func_list) * (func_count + 1)); i = 0; while (list) { diff --git a/trunk/tools/perf/util/trace-event-read.c b/trunk/tools/perf/util/trace-event-read.c index 342dfdd43f87..1744422cafcb 100644 --- a/trunk/tools/perf/util/trace-event-read.c +++ b/trunk/tools/perf/util/trace-event-read.c @@ -145,8 +145,9 @@ static void read_proc_kallsyms(void) if (!size) return; - buf = malloc_or_die(size); + buf = malloc_or_die(size + 1); read_or_die(buf, size); + buf[size] = '\0'; parse_proc_kallsyms(buf, size);