As warned by gcc:
ras-report.c: In function ‘setup_report_socket’:
ras-report.c:36:2: warning: ‘strncpy’ output truncated before terminating nul copying 25 bytes from a string of the same length [-Wstringop-truncation]
strncpy(addr.sun_path, ABRT_SOCKET, strlen(ABRT_SOCKET));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The strncpy logic there is wrong. Fix it and be sure to have a NUL
terminated string filled at addr.sun_path.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
memset(&addr, 0, sizeof(struct sockaddr_un));
addr.sun_family = AF_UNIX;
- strncpy(addr.sun_path, ABRT_SOCKET, strlen(ABRT_SOCKET));
+ strncpy(addr.sun_path, ABRT_SOCKET, sizeof(addr.sun_path));
+ addr.sun_path[sizeof(addr.sun_path) - 1] = '\0';
rc = connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr_un));
if (rc < 0){