[PATCH 1/4] perf_counter: fix off-by-one on the string lengths

From: Peter Zijlstra
Date: Thu Apr 09 2009 - 04:55:26 EST


strlen() does _not_ include the terminating \0.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
---
kernel/perf_counter.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Index: linux-2.6/kernel/perf_counter.c
===================================================================
--- linux-2.6.orig/kernel/perf_counter.c
+++ linux-2.6/kernel/perf_counter.c
@@ -1989,7 +1989,7 @@ static void perf_counter_comm_event(stru
unsigned int size;
char *comm = comm_event->task->comm;

- size = ALIGN(strlen(comm), sizeof(u64));
+ size = ALIGN(strlen(comm)+1, sizeof(u64));

comm_event->comm = comm;
comm_event->comm_size = size;
@@ -2109,7 +2109,7 @@ static void perf_counter_mmap_event(stru
}

got_name:
- size = ALIGN(strlen(name), sizeof(u64));
+ size = ALIGN(strlen(name)+1, sizeof(u64));

mmap_event->file_name = name;
mmap_event->file_size = size;

--

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/