core/tcp: Prevent buffer overflow found by covscan

buffer_size_warning: Calling strncpy with a maximum size argument of 108 bytes on destination array "addr.sun_path" of size 108 bytes might leave the destination string unterminated.
This commit is contained in:
Ondrej Holy 2018-08-17 16:25:20 +02:00
parent 26bc52f79c
commit 1a413b5b4e

View File

@ -736,7 +736,7 @@ static int freerdp_uds_connect(const char* path)
#ifndef _WIN32
int status;
int sockfd;
struct sockaddr_un addr;
struct sockaddr_un addr = { 0 };
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
if (sockfd == -1)
@ -746,7 +746,7 @@ static int freerdp_uds_connect(const char* path)
}
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, path, sizeof(addr.sun_path));
strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1);
status = connect(sockfd, (struct sockaddr*) &addr, sizeof(addr));
if (status < 0)