Skip to contentSkip to conversation

trace: using strlcpy instead of strncpy

PATCH In review Zhao Hongjiang 2 participants 2 messages Jun 20, 2013

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

PATCH 1/1 trace: using strlcpy instead of strncpy

for NUL terminated string, need alway set '\0' in the end.

---
 include/trace/events/sock.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/trace/events/sock.h +1 -1
index 779abb9..333d8b5 100644
@@ -44,7 +44,7 @@ TRACE_EVENT(sock_exceed_buf_limit,
 	),
 
 	TP_fast_assign(
-		strncpy(__entry->name, prot->name, 32);
+		strlcpy(__entry->name, prot->name, 32);
 		__entry->sysctl_mem = prot->sysctl_mem;
 		__entry->allocated = allocated;
 		__entry->sysctl_rmem = prot->sysctl_rmem[0];
Signature · 1 line
1.7.1
maintainer
#1 lore raw

This fix is to a networking tracepoint. It should go through the networking folks.

-- Steve

Quoted 20 lines · Zhao Hongjiang

for NUL terminated string, need alway set '\0' in the end.

---
 include/trace/events/sock.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/trace/events/sock.h +1 -1
index 779abb9..333d8b5 100644
@@ -44,7 +44,7 @@ TRACE_EVENT(sock_exceed_buf_limit,
 	),
 
 	TP_fast_assign(
-		strncpy(__entry->name, prot->name, 32);
+		strlcpy(__entry->name, prot->name, 32);
 		__entry->sysctl_mem = prot->sysctl_mem;
 		__entry->allocated = allocated;
 		__entry->sysctl_rmem = prot->sysctl_rmem[0];