[PATCH] kernel: events: strncpy, always be sure of NUL terminated.
for NUL terminated string, always be sure of '\0' at the end. in our case, need return value, so still use strncpy (strlcpy return the size, not the pointer) Signed-off-by: Chen Gang --- kernel/events/core.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 4757941..bdc0e25 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -4752,7 +4752,8 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event) } else { if (arch_vma_name(mmap_event->vma)) { name = strncpy(tmp, arch_vma_name(mmap_event->vma), - sizeof(tmp)); + sizeof(tmp) - 1); + tmp[sizeof(tmp) - 1] = '\0'; goto got_name; } -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] kernel: events: strncpy, always be sure of NUL terminated.
for NUL terminated string, always be sure of '\0' at the end. in our case, need return value, so still use strncpy (strlcpy return the size, not the pointer) Signed-off-by: Chen Gang gang.c...@asianux.com --- kernel/events/core.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 4757941..bdc0e25 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -4752,7 +4752,8 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event) } else { if (arch_vma_name(mmap_event-vma)) { name = strncpy(tmp, arch_vma_name(mmap_event-vma), - sizeof(tmp)); + sizeof(tmp) - 1); + tmp[sizeof(tmp) - 1] = '\0'; goto got_name; } -- 1.7.7.6 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/