mirror of
https://github.com/curl/curl.git
synced 2025-09-10 22:22:43 +03:00
tests/server/util.c: remove use of strncpy
... and ban the function in code in this directory. Closes #15213
This commit is contained in:
parent
08949637d5
commit
45b388fdc7
|
@ -49,6 +49,7 @@ path = [
|
|||
"lib/vtls/.checksrc",
|
||||
"src/.checksrc",
|
||||
"tests/libtest/.checksrc",
|
||||
"tests/server/.checksrc",
|
||||
]
|
||||
SPDX-FileCopyrightText = "Daniel Stenberg, <daniel@haxx.se>, et al."
|
||||
SPDX-License-Identifier = "curl"
|
||||
|
|
1
tests/server/.checksrc
Normal file
1
tests/server/.checksrc
Normal file
|
@ -0,0 +1 @@
|
|||
enable STRNCPY
|
|
@ -50,7 +50,7 @@ AM_CPPFLAGS += -DCURL_NO_GETADDRINFO_OVERRIDE
|
|||
# Makefile.inc provides neat definitions
|
||||
include Makefile.inc
|
||||
|
||||
EXTRA_DIST = base64.pl CMakeLists.txt
|
||||
EXTRA_DIST = base64.pl CMakeLists.txt .checksrc
|
||||
|
||||
CHECKSRC = $(CS_$(V))
|
||||
CS_0 = @echo " RUN " $@;
|
||||
|
|
|
@ -834,13 +834,19 @@ void restore_signal_handlers(bool keep_sigalrm)
|
|||
#ifdef USE_UNIX_SOCKETS
|
||||
|
||||
int bind_unix_socket(curl_socket_t sock, const char *unix_socket,
|
||||
struct sockaddr_un *sau) {
|
||||
struct sockaddr_un *sau)
|
||||
{
|
||||
int error;
|
||||
int rc;
|
||||
size_t len = strlen(unix_socket);
|
||||
|
||||
memset(sau, 0, sizeof(struct sockaddr_un));
|
||||
sau->sun_family = AF_UNIX;
|
||||
strncpy(sau->sun_path, unix_socket, sizeof(sau->sun_path) - 1);
|
||||
if(len >= sizeof(sau->sun_path) - 1) {
|
||||
logmsg("Too long unix socket domain path (%zd)", len);
|
||||
return -1;
|
||||
}
|
||||
strcpy(sau->sun_path, unix_socket);
|
||||
rc = bind(sock, (struct sockaddr*)sau, sizeof(struct sockaddr_un));
|
||||
if(0 != rc && SOCKERRNO == EADDRINUSE) {
|
||||
struct_stat statbuf;
|
||||
|
|
Loading…
Reference in New Issue
Block a user