For NUL terminated string, always make sure that there's '\0' at the end. In our case we need a return value, so still use strncpy() and fix up the tail explicitly. (strlcpy() returns the size, not the pointer)
Unified · Split
| @@ -4737,7 +4737,8 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event) · 4736 unmodified lines | ||
| 4737 | 4737 | } else { |
| 4738 | 4738 | if (arch_vma_name(mmap_event->vma)) { |
| 4739 | 4739 | name = strncpy(tmp, arch_vma_name(mmap_event->vma), |
| 4740 | − sizeof(tmp)); | |
| 4740 | + sizeof(tmp) - 1); | |
| 4741 | + tmp[sizeof(tmp) - 1] = '\0'; | |
| 4741 | 4742 | goto got_name; |
| 4742 | 4743 | } |
| 4743 | 4744 | |