summaryrefslogtreecommitdiffstats
path: root/Utilities/cmcurl/lib/curl_gethostname.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-09-18 15:42:10 (GMT)
committerBrad King <brad.king@kitware.com>2024-09-18 15:51:18 (GMT)
commitce908c42a37fd56325aff80d2c63a4a811ce9389 (patch)
tree98319de414b3d57d58a2e7710985b101fcb022e5 /Utilities/cmcurl/lib/curl_gethostname.c
parent862bd5defc382e6863ef989aac74e0587925b30d (diff)
parent1a2b208170bd650f328800afd5584a5d056f195d (diff)
downloadCMake-ce908c42a37fd56325aff80d2c63a4a811ce9389.zip
CMake-ce908c42a37fd56325aff80d2c63a4a811ce9389.tar.gz
CMake-ce908c42a37fd56325aff80d2c63a4a811ce9389.tar.bz2
Merge branch 'upstream-curl' into update-curl
* upstream-curl: curl 2024-09-18 (7eb8c048)
Diffstat (limited to 'Utilities/cmcurl/lib/curl_gethostname.c')
-rw-r--r--Utilities/cmcurl/lib/curl_gethostname.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/Utilities/cmcurl/lib/curl_gethostname.c b/Utilities/cmcurl/lib/curl_gethostname.c
index cd11123..617a8ad 100644
--- a/Utilities/cmcurl/lib/curl_gethostname.c
+++ b/Utilities/cmcurl/lib/curl_gethostname.c
@@ -39,15 +39,6 @@
*
* Note: The function always returns the un-qualified hostname rather
* than being provider dependent.
- *
- * For libcurl shared library release builds the test suite preloads
- * another shared library named libhostname using the LD_PRELOAD
- * mechanism which intercepts, and might override, the gethostname()
- * function call. In this case a given platform must support the
- * LD_PRELOAD mechanism and additionally have environment variable
- * CURL_GETHOSTNAME set in order to override the returned hostname.
- *
- * For libcurl static library release builds no overriding takes place.
*/
int Curl_gethostname(char * const name, GETHOSTNAME_TYPE_ARG2 namelen)
@@ -68,7 +59,10 @@ int Curl_gethostname(char * const name, GETHOSTNAME_TYPE_ARG2 namelen)
/* Override hostname when environment variable CURL_GETHOSTNAME is set */
const char *force_hostname = getenv("CURL_GETHOSTNAME");
if(force_hostname) {
- strncpy(name, force_hostname, namelen - 1);
+ if(strlen(force_hostname) < (size_t)namelen)
+ strcpy(name, force_hostname);
+ else
+ return 1; /* can't do it */
err = 0;
}
else {
@@ -78,9 +72,6 @@ int Curl_gethostname(char * const name, GETHOSTNAME_TYPE_ARG2 namelen)
#else /* DEBUGBUILD */
- /* The call to system's gethostname() might get intercepted by the
- libhostname library when libcurl is built as a non-debug shared
- library when running the test suite. */
name[0] = '\0';
err = gethostname(name, namelen);