mirror of
https://github.com/moparisthebest/curl
synced 2024-11-14 05:25:06 -05:00
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
This commit is contained in:
parent
7fa1578471
commit
878214df44
@ -697,8 +697,8 @@ cleanup:
|
|||||||
return slist;
|
return slist;
|
||||||
}
|
}
|
||||||
|
|
||||||
LARGE_INTEGER Curl_freq;
|
LARGE_INTEGER tool_freq;
|
||||||
bool Curl_isVistaOrGreater;
|
bool tool_isVistaOrGreater;
|
||||||
|
|
||||||
CURLcode win32_init(void)
|
CURLcode win32_init(void)
|
||||||
{
|
{
|
||||||
@ -713,13 +713,13 @@ CURLcode win32_init(void)
|
|||||||
VER_SET_CONDITION(mask, VER_MINORVERSION, op);
|
VER_SET_CONDITION(mask, VER_MINORVERSION, op);
|
||||||
|
|
||||||
if(VerifyVersionInfoA(&osvi, (VER_MAJORVERSION | VER_MINORVERSION), mask))
|
if(VerifyVersionInfoA(&osvi, (VER_MAJORVERSION | VER_MINORVERSION), mask))
|
||||||
Curl_isVistaOrGreater = true;
|
tool_isVistaOrGreater = true;
|
||||||
else if(GetLastError() == ERROR_OLD_WIN_VERSION)
|
else if(GetLastError() == ERROR_OLD_WIN_VERSION)
|
||||||
Curl_isVistaOrGreater = false;
|
tool_isVistaOrGreater = false;
|
||||||
else
|
else
|
||||||
return CURLE_FAILED_INIT;
|
return CURLE_FAILED_INIT;
|
||||||
|
|
||||||
QueryPerformanceFrequency(&Curl_freq);
|
QueryPerformanceFrequency(&tool_freq);
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,9 +401,9 @@ static void SHA256_Final(unsigned char digest[32], SHA256_CTX *ctx)
|
|||||||
|
|
||||||
const digest_params MD5_DIGEST_PARAMS[] = {
|
const digest_params MD5_DIGEST_PARAMS[] = {
|
||||||
{
|
{
|
||||||
CURLX_FUNCTION_CAST(Curl_digest_init_func, MD5_Init),
|
CURLX_FUNCTION_CAST(digest_init_func, MD5_Init),
|
||||||
CURLX_FUNCTION_CAST(Curl_digest_update_func, MD5_Update),
|
CURLX_FUNCTION_CAST(digest_update_func, MD5_Update),
|
||||||
CURLX_FUNCTION_CAST(Curl_digest_final_func, MD5_Final),
|
CURLX_FUNCTION_CAST(digest_final_func, MD5_Final),
|
||||||
sizeof(MD5_CTX),
|
sizeof(MD5_CTX),
|
||||||
16
|
16
|
||||||
}
|
}
|
||||||
@ -411,9 +411,9 @@ const digest_params MD5_DIGEST_PARAMS[] = {
|
|||||||
|
|
||||||
const digest_params SHA1_DIGEST_PARAMS[] = {
|
const digest_params SHA1_DIGEST_PARAMS[] = {
|
||||||
{
|
{
|
||||||
CURLX_FUNCTION_CAST(Curl_digest_init_func, SHA1_Init),
|
CURLX_FUNCTION_CAST(digest_init_func, SHA1_Init),
|
||||||
CURLX_FUNCTION_CAST(Curl_digest_update_func, SHA1_Update),
|
CURLX_FUNCTION_CAST(digest_update_func, SHA1_Update),
|
||||||
CURLX_FUNCTION_CAST(Curl_digest_final_func, SHA1_Final),
|
CURLX_FUNCTION_CAST(digest_final_func, SHA1_Final),
|
||||||
sizeof(SHA_CTX),
|
sizeof(SHA_CTX),
|
||||||
20
|
20
|
||||||
}
|
}
|
||||||
@ -421,9 +421,9 @@ const digest_params SHA1_DIGEST_PARAMS[] = {
|
|||||||
|
|
||||||
const digest_params SHA256_DIGEST_PARAMS[] = {
|
const digest_params SHA256_DIGEST_PARAMS[] = {
|
||||||
{
|
{
|
||||||
CURLX_FUNCTION_CAST(Curl_digest_init_func, SHA256_Init),
|
CURLX_FUNCTION_CAST(digest_init_func, SHA256_Init),
|
||||||
CURLX_FUNCTION_CAST(Curl_digest_update_func, SHA256_Update),
|
CURLX_FUNCTION_CAST(digest_update_func, SHA256_Update),
|
||||||
CURLX_FUNCTION_CAST(Curl_digest_final_func, SHA256_Final),
|
CURLX_FUNCTION_CAST(digest_final_func, SHA256_Final),
|
||||||
sizeof(SHA256_CTX),
|
sizeof(SHA256_CTX),
|
||||||
32
|
32
|
||||||
}
|
}
|
||||||
@ -457,7 +457,7 @@ static const metalink_digest_alias digest_aliases[] = {
|
|||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
digest_context *Curl_digest_init(const digest_params *dparams)
|
static digest_context *digest_init(const digest_params *dparams)
|
||||||
{
|
{
|
||||||
digest_context *ctxt;
|
digest_context *ctxt;
|
||||||
|
|
||||||
@ -485,16 +485,16 @@ digest_context *Curl_digest_init(const digest_params *dparams)
|
|||||||
return ctxt;
|
return ctxt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Curl_digest_update(digest_context *context,
|
static int digest_update(digest_context *context,
|
||||||
const unsigned char *data,
|
const unsigned char *data,
|
||||||
unsigned int len)
|
unsigned int len)
|
||||||
{
|
{
|
||||||
(*context->digest_hash->digest_update)(context->digest_hashctx, data, len);
|
(*context->digest_hash->digest_update)(context->digest_hashctx, data, len);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Curl_digest_final(digest_context *context, unsigned char *result)
|
static int digest_final(digest_context *context, unsigned char *result)
|
||||||
{
|
{
|
||||||
if(result)
|
if(result)
|
||||||
(*context->digest_hash->digest_final)(result, context->digest_hashctx);
|
(*context->digest_hash->digest_final)(result, context->digest_hashctx);
|
||||||
@ -551,7 +551,7 @@ static int check_hash(const char *filename,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dctx = Curl_digest_init(digest_def->dparams);
|
dctx = digest_init(digest_def->dparams);
|
||||||
if(!dctx) {
|
if(!dctx) {
|
||||||
fprintf(error, "Metalink: validating (%s) [%s] FAILED (%s)\n", filename,
|
fprintf(error, "Metalink: validating (%s) [%s] FAILED (%s)\n", filename,
|
||||||
digest_def->hash_name, "failed to initialize hash algorithm");
|
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);
|
result = malloc(digest_def->dparams->digest_resultlen);
|
||||||
if(!result) {
|
if(!result) {
|
||||||
close(fd);
|
close(fd);
|
||||||
Curl_digest_final(dctx, NULL);
|
digest_final(dctx, NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
while(1) {
|
while(1) {
|
||||||
@ -574,13 +574,13 @@ static int check_hash(const char *filename,
|
|||||||
else if(len == -1) {
|
else if(len == -1) {
|
||||||
fprintf(error, "Metalink: validating (%s) [%s] FAILED (%s)\n", filename,
|
fprintf(error, "Metalink: validating (%s) [%s] FAILED (%s)\n", filename,
|
||||||
digest_def->hash_name, strerror(errno));
|
digest_def->hash_name, strerror(errno));
|
||||||
Curl_digest_final(dctx, result);
|
digest_final(dctx, result);
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
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,
|
check_ok = memcmp(result, digest,
|
||||||
digest_def->dparams->digest_resultlen) == 0;
|
digest_def->dparams->digest_resultlen) == 0;
|
||||||
/* sha*sum style verdict output */
|
/* sha*sum style verdict output */
|
||||||
|
@ -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
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -28,19 +28,19 @@ struct GlobalConfig;
|
|||||||
struct OperationConfig;
|
struct OperationConfig;
|
||||||
|
|
||||||
/* returns 1 for success, 0 otherwise (we use OpenSSL *_Init fncs directly) */
|
/* 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,
|
typedef void (*digest_update_func)(void *context,
|
||||||
const unsigned char *data,
|
const unsigned char *data,
|
||||||
unsigned int len);
|
unsigned int len);
|
||||||
typedef void (* Curl_digest_final_func)(unsigned char *result, void *context);
|
typedef void (*digest_final_func)(unsigned char *result, void *context);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Curl_digest_init_func digest_init; /* Initialize context procedure */
|
digest_init_func digest_init; /* Initialize context procedure */
|
||||||
Curl_digest_update_func digest_update; /* Update context with data */
|
digest_update_func digest_update; /* Update context with data */
|
||||||
Curl_digest_final_func digest_final; /* Get final result procedure */
|
digest_final_func digest_final; /* Get final result procedure */
|
||||||
unsigned int digest_ctxtsize; /* Context structure size */
|
unsigned int digest_ctxtsize; /* Context structure size */
|
||||||
unsigned int digest_resultlen; /* Result length (bytes) */
|
unsigned int digest_resultlen; /* Result length (bytes) */
|
||||||
} digest_params;
|
} digest_params;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -48,12 +48,6 @@ typedef struct {
|
|||||||
void *digest_hashctx; /* Hash function context */
|
void *digest_hashctx; /* Hash function context */
|
||||||
} digest_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 {
|
typedef struct {
|
||||||
const char *hash_name;
|
const char *hash_name;
|
||||||
const digest_params *dparams;
|
const digest_params *dparams;
|
||||||
|
@ -28,19 +28,19 @@
|
|||||||
#if defined(WIN32) && !defined(MSDOS)
|
#if defined(WIN32) && !defined(MSDOS)
|
||||||
|
|
||||||
/* set in win32_init() */
|
/* set in win32_init() */
|
||||||
extern LARGE_INTEGER Curl_freq;
|
extern LARGE_INTEGER tool_freq;
|
||||||
extern bool Curl_isVistaOrGreater;
|
extern bool tool_isVistaOrGreater;
|
||||||
|
|
||||||
/* In case of bug fix this function has a counterpart in timeval.c */
|
/* In case of bug fix this function has a counterpart in timeval.c */
|
||||||
struct timeval tvnow(void)
|
struct timeval tvnow(void)
|
||||||
{
|
{
|
||||||
struct timeval now;
|
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;
|
LARGE_INTEGER count;
|
||||||
QueryPerformanceCounter(&count);
|
QueryPerformanceCounter(&count);
|
||||||
now.tv_sec = (long)(count.QuadPart / Curl_freq.QuadPart);
|
now.tv_sec = (long)(count.QuadPart / tool_freq.QuadPart);
|
||||||
now.tv_usec = (long)((count.QuadPart % Curl_freq.QuadPart) * 1000000 /
|
now.tv_usec = (long)((count.QuadPart % tool_freq.QuadPart) * 1000000 /
|
||||||
Curl_freq.QuadPart);
|
tool_freq.QuadPart);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Disable /analyze warning that GetTickCount64 is preferred */
|
/* Disable /analyze warning that GetTickCount64 is preferred */
|
||||||
|
Loading…
Reference in New Issue
Block a user