Skip to content

Commit 2105b8c

Browse files
author
Zisso
committed
Fix compilation issues including C4996 and C4477
1 parent 7d9ad78 commit 2105b8c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

wsl-samples/afunix-wsl-interop/windows_server/af_unix_win_server.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#undef UNICODE
22

3-
#include <windows.h>
43
#include <winsock2.h>
4+
#include <windows.h>
55
#include <ws2tcpip.h>
66
#include <afunix.h>
77
#include <stdlib.h>
@@ -36,7 +36,7 @@ int __cdecl main(void)
3636

3737
memset(&ServerSocket, 0, sizeof(ServerSocket));
3838
ServerSocket.sun_family = AF_UNIX;
39-
strncpy(ServerSocket.sun_path, SERVER_SOCKET, strlen(SERVER_SOCKET));
39+
strncpy_s(ServerSocket.sun_path, sizeof ServerSocket.sun_path, SERVER_SOCKET, (sizeof SERVER_SOCKET) - 1);
4040

4141
// Bind the socket to the path.
4242
Result = bind(ListenSocket, (struct sockaddr *)&ServerSocket, sizeof(ServerSocket));
@@ -61,7 +61,7 @@ int __cdecl main(void)
6161
}
6262

6363
printf("Accepted a connection.\n" );
64-
printf("Relayed %d bytes: '%s'\n", strlen(SendBuffer), SendBuffer);
64+
printf("Relayed %zu bytes: '%s'\n", strlen(SendBuffer), SendBuffer);
6565
// Send some data.
6666
SendResult = send(ClientSocket, SendBuffer, (int)strlen(SendBuffer), 0 );
6767
if (SendResult == SOCKET_ERROR) {

0 commit comments

Comments
 (0)