Skip to contentSkip to conversation

trace: strlen() return doesn't account for the NULL

PATCH In review Dan Carpenter 1 participant 2 messages Jul 10, 2010 – Jul 23, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace: strlen() return doesn't account for the NULL

We need to add one to the strlen() return because of the NULL character. The type->name here generally comes from the kernel and I don't think any of them come close to being MAX_TRACER_SIZE (100) characters long so this is basically a cleanup.

kernel/trace/trace.c +1 -1
index 086d363..5f13c35 100644
@@ -729,7 +729,7 @@ __acquires(kernel_lock)
 		return -1;
 	}
 
-	if (strlen(type->name) > MAX_TRACER_SIZE) {
+	if (strlen(type->name) >= MAX_TRACER_SIZE) {
 		pr_info("Tracer has a name longer than %d\n", MAX_TRACER_SIZE);
 		return -1;
 	}
#1 lore raw
Commit-ID:  24a461d537f49f9da6533d83100999ea08c6c755
Gitweb:     http://git.kernel.org/tip/24a461d537f49f9da6533d83100999ea08c6c755
Author:     Dan Carpenter <[email protected]>
AuthorDate: Sat, 10 Jul 2010 12:06:44 +0200
Committer:  Steven Rostedt <[email protected]>
CommitDate: Thu, 22 Jul 2010 14:56:41 -0400

trace: strlen() return doesn't account for the NULL

We need to add one to the strlen() return because of the NULL character. The type->name here generally comes from the kernel and I don't think any of them come close to being MAX_TRACER_SIZE (100) characters long so this is basically a cleanup.

LKML-Reference: <20100710100644.GV19184@bicker>

---
 kernel/trace/trace.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/trace/trace.c +1 -1
index f7488f4..cacb6f0 100644
@@ -739,7 +739,7 @@ __acquires(kernel_lock)
 		return -1;
 	}
 
-	if (strlen(type->name) > MAX_TRACER_SIZE) {
+	if (strlen(type->name) >= MAX_TRACER_SIZE) {
 		pr_info("Tracer has a name longer than %d\n", MAX_TRACER_SIZE);
 		return -1;
 	}