aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-04-13 23:46:18 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-04-14 08:12:27 +0200
commit878214df44a41eef49b65039ab0cdfdbf847a5fe (patch)
tree1babc575b299757800890bdc7454490468cccbc3 /src
parent7fa1578471697eac9726261c3dcd06ded994aa21 (diff)
tool: do not declare functions with Curl_ prefix
To avoid collision risks with private libcurl symbols when linked with static versions (or just versions not hiding internal symbols). Reported-by: hydra3333 on github Fixes #5219 Closes #5234
Diffstat (limited to 'src')
-rw-r--r--src/tool_doswin.c10
-rw-r--r--src/tool_metalink.c38
-rw-r--r--src/tool_metalink.h28
-rw-r--r--src/tool_util.c12
4 files changed, 41 insertions, 47 deletions
diff --git a/src/tool_doswin.c b/src/tool_doswin.c
index 221e3864b..b7df3e615 100644
--- a/src/tool_doswin.c
+++ b/src/tool_doswin.c
@@ -697,8 +697,8 @@ cleanup:
return slist;
}
-LARGE_INTEGER Curl_freq;
-bool Curl_isVistaOrGreater;
+LARGE_INTEGER tool_freq;
+bool tool_isVistaOrGreater;
CURLcode win32_init(void)
{
@@ -713,13 +713,13 @@ CURLcode win32_init(void)
VER_SET_CONDITION(mask, VER_MINORVERSION, op);
if(VerifyVersionInfoA(&osvi, (VER_MAJORVERSION | VER_MINORVERSION), mask))
- Curl_isVistaOrGreater = true;
+ tool_isVistaOrGreater = true;
else if(GetLastError() == ERROR_OLD_WIN_VERSION)
- Curl_isVistaOrGreater = false;
+ tool_isVistaOrGreater = false;
else
return CURLE_FAILED_INIT;
- QueryPerformanceFrequency(&Curl_freq);
+ QueryPerformanceFrequency(&tool_freq);
return CURLE_OK;
}
diff --git a/src/tool_metalink.c b/src/tool_metalink.c
index e8629353f..fce18d5a4 100644
--- a/src/tool_metalink.c
+++ b/src/tool_metalink.c
@@ -401,9 +401,9 @@ static void SHA256_Final(unsigned char digest[32], SHA256_CTX *ctx)
const digest_params MD5_DIGEST_PARAMS[] = {
{
- CURLX_FUNCTION_CAST(Curl_digest_init_func, MD5_Init),
- CURLX_FUNCTION_CAST(Curl_digest_update_func, MD5_Update),
- CURLX_FUNCTION_CAST(Curl_digest_final_func, MD5_Final),
+ CURLX_FUNCTION_CAST(digest_init_func, MD5_Init),
+ CURLX_FUNCTION_CAST(digest_update_func, MD5_Update),
+ CURLX_FUNCTION_CAST(digest_final_func, MD5_Final),
sizeof(MD5_CTX),
16
}
@@ -411,9 +411,9 @@ const digest_params MD5_DIGEST_PARAMS[] = {
const digest_params SHA1_DIGEST_PARAMS[] = {
{
- CURLX_FUNCTION_CAST(Curl_digest_init_func, SHA1_Init),
- CURLX_FUNCTION_CAST(Curl_digest_update_func, SHA1_Update),
- CURLX_FUNCTION_CAST(Curl_digest_final_func, SHA1_Final),
+ CURLX_FUNCTION_CAST(digest_init_func, SHA1_Init),
+ CURLX_FUNCTION_CAST(digest_update_func, SHA1_Update),
+ CURLX_FUNCTION_CAST(digest_final_func, SHA1_Final),
sizeof(SHA_CTX),
20
}
@@ -421,9 +421,9 @@ const digest_params SHA1_DIGEST_PARAMS[] = {
const digest_params SHA256_DIGEST_PARAMS[] = {
{
- CURLX_FUNCTION_CAST(Curl_digest_init_func, SHA256_Init),
- CURLX_FUNCTION_CAST(Curl_digest_update_func, SHA256_Update),
- CURLX_FUNCTION_CAST(Curl_digest_final_func, SHA256_Final),
+ CURLX_FUNCTION_CAST(digest_init_func, SHA256_Init),
+ CURLX_FUNCTION_CAST(digest_update_func, SHA256_Update),
+ CURLX_FUNCTION_CAST(digest_final_func, SHA256_Final),
sizeof(SHA256_CTX),
32
}
@@ -457,7 +457,7 @@ static const metalink_digest_alias digest_aliases[] = {
{NULL, NULL}
};
-digest_context *Curl_digest_init(const digest_params *dparams)
+static digest_context *digest_init(const digest_params *dparams)
{
digest_context *ctxt;
@@ -485,16 +485,16 @@ digest_context *Curl_digest_init(const digest_params *dparams)
return ctxt;
}
-int Curl_digest_update(digest_context *context,
- const unsigned char *data,
- unsigned int len)
+static int digest_update(digest_context *context,
+ const unsigned char *data,
+ unsigned int len)
{
(*context->digest_hash->digest_update)(context->digest_hashctx, data, len);
return 0;
}
-int Curl_digest_final(digest_context *context, unsigned char *result)
+static int digest_final(digest_context *context, unsigned char *result)
{
if(result)
(*context->digest_hash->digest_final)(result, context->digest_hashctx);
@@ -551,7 +551,7 @@ static int check_hash(const char *filename,
return -1;
}
- dctx = Curl_digest_init(digest_def->dparams);
+ dctx = digest_init(digest_def->dparams);
if(!dctx) {
fprintf(error, "Metalink: validating (%s) [%s] FAILED (%s)\n", filename,
digest_def->hash_name, "failed to initialize hash algorithm");
@@ -562,7 +562,7 @@ static int check_hash(const char *filename,
result = malloc(digest_def->dparams->digest_resultlen);
if(!result) {
close(fd);
- Curl_digest_final(dctx, NULL);
+ digest_final(dctx, NULL);
return -1;
}
while(1) {
@@ -574,13 +574,13 @@ static int check_hash(const char *filename,
else if(len == -1) {
fprintf(error, "Metalink: validating (%s) [%s] FAILED (%s)\n", filename,
digest_def->hash_name, strerror(errno));
- Curl_digest_final(dctx, result);
+ digest_final(dctx, result);
close(fd);
return -1;
}
- Curl_digest_update(dctx, buf, (unsigned int)len);
+ digest_update(dctx, buf, (unsigned int)len);
}
- Curl_digest_final(dctx, result);
+ digest_final(dctx, result);
check_ok = memcmp(result, digest,
digest_def->dparams->digest_resultlen) == 0;
/* sha*sum style verdict output */
diff --git a/src/tool_metalink.h b/src/tool_metalink.h
index f5ec306f7..db2f702e5 100644
--- a/src/tool_metalink.h
+++ b/src/tool_metalink.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2014, 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -28,19 +28,19 @@ struct GlobalConfig;
struct OperationConfig;
/* returns 1 for success, 0 otherwise (we use OpenSSL *_Init fncs directly) */
-typedef int (* Curl_digest_init_func)(void *context);
+typedef int (*digest_init_func)(void *context);
-typedef void (* Curl_digest_update_func)(void *context,
- const unsigned char *data,
- unsigned int len);
-typedef void (* Curl_digest_final_func)(unsigned char *result, void *context);
+typedef void (*digest_update_func)(void *context,
+ const unsigned char *data,
+ unsigned int len);
+typedef void (*digest_final_func)(unsigned char *result, void *context);
typedef struct {
- Curl_digest_init_func digest_init; /* Initialize context procedure */
- Curl_digest_update_func digest_update; /* Update context with data */
- Curl_digest_final_func digest_final; /* Get final result procedure */
- unsigned int digest_ctxtsize; /* Context structure size */
- unsigned int digest_resultlen; /* Result length (bytes) */
+ digest_init_func digest_init; /* Initialize context procedure */
+ digest_update_func digest_update; /* Update context with data */
+ digest_final_func digest_final; /* Get final result procedure */
+ unsigned int digest_ctxtsize; /* Context structure size */
+ unsigned int digest_resultlen; /* Result length (bytes) */
} digest_params;
typedef struct {
@@ -48,12 +48,6 @@ typedef struct {
void *digest_hashctx; /* Hash function context */
} digest_context;
-digest_context * Curl_digest_init(const digest_params *dparams);
-int Curl_digest_update(digest_context *context,
- const unsigned char *data,
- unsigned int len);
-int Curl_digest_final(digest_context *context, unsigned char *result);
-
typedef struct {
const char *hash_name;
const digest_params *dparams;
diff --git a/src/tool_util.c b/src/tool_util.c
index 8bbfae03e..3ca13e7cb 100644
--- a/src/tool_util.c
+++ b/src/tool_util.c
@@ -28,19 +28,19 @@
#if defined(WIN32) && !defined(MSDOS)
/* set in win32_init() */
-extern LARGE_INTEGER Curl_freq;
-extern bool Curl_isVistaOrGreater;
+extern LARGE_INTEGER tool_freq;
+extern bool tool_isVistaOrGreater;
/* In case of bug fix this function has a counterpart in timeval.c */
struct timeval tvnow(void)
{
struct timeval now;
- if(Curl_isVistaOrGreater) { /* QPC timer might have issues pre-Vista */
+ if(tool_isVistaOrGreater) { /* QPC timer might have issues pre-Vista */
LARGE_INTEGER count;
QueryPerformanceCounter(&count);
- now.tv_sec = (long)(count.QuadPart / Curl_freq.QuadPart);
- now.tv_usec = (long)((count.QuadPart % Curl_freq.QuadPart) * 1000000 /
- Curl_freq.QuadPart);
+ now.tv_sec = (long)(count.QuadPart / tool_freq.QuadPart);
+ now.tv_usec = (long)((count.QuadPart % tool_freq.QuadPart) * 1000000 /
+ tool_freq.QuadPart);
}
else {
/* Disable /analyze warning that GetTickCount64 is preferred */