Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TLMSP curl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CYBER - Cyber Security
TS 103 523 MSP
TLMSP
TLMSP curl
Commits
dca8ae5f
Commit
dca8ae5f
authored
12 years ago
by
Kamil Dudka
Browse files
Options
Downloads
Patches
Plain Diff
tool_metalink: allow to handle failure of hash alg initialization
parent
cf75a646
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/tool_metalink.c
+32
-10
32 additions, 10 deletions
src/tool_metalink.c
src/tool_metalink.h
+3
-3
3 additions, 3 deletions
src/tool_metalink.h
with
35 additions
and
13 deletions
src/tool_metalink.c
+
32
−
10
View file @
dca8ae5f
...
...
@@ -112,9 +112,10 @@ struct win32_crypto_hash {
#ifdef USE_GNUTLS_NETTLE
static
void
MD5_Init
(
MD5_CTX
*
ctx
)
static
int
MD5_Init
(
MD5_CTX
*
ctx
)
{
md5_init
(
ctx
);
return
0
;
}
static
void
MD5_Update
(
MD5_CTX
*
ctx
,
...
...
@@ -129,9 +130,10 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
md5_digest
(
ctx
,
16
,
digest
);
}
static
void
SHA1_Init
(
SHA_CTX
*
ctx
)
static
int
SHA1_Init
(
SHA_CTX
*
ctx
)
{
sha1_init
(
ctx
);
return
0
;
}
static
void
SHA1_Update
(
SHA_CTX
*
ctx
,
...
...
@@ -146,9 +148,10 @@ static void SHA1_Final(unsigned char digest[20], SHA_CTX *ctx)
sha1_digest
(
ctx
,
20
,
digest
);
}
static
void
SHA256_Init
(
SHA256_CTX
*
ctx
)
static
int
SHA256_Init
(
SHA256_CTX
*
ctx
)
{
sha256_init
(
ctx
);
return
0
;
}
static
void
SHA256_Update
(
SHA256_CTX
*
ctx
,
...
...
@@ -165,9 +168,10 @@ static void SHA256_Final(unsigned char digest[32], SHA256_CTX *ctx)
#elif defined(USE_GNUTLS)
static
void
MD5_Init
(
MD5_CTX
*
ctx
)
static
int
MD5_Init
(
MD5_CTX
*
ctx
)
{
gcry_md_open
(
ctx
,
GCRY_MD_MD5
,
0
);
return
0
;
}
static
void
MD5_Update
(
MD5_CTX
*
ctx
,
...
...
@@ -183,9 +187,10 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
gcry_md_close
(
*
ctx
);
}
static
void
SHA1_Init
(
SHA_CTX
*
ctx
)
static
int
SHA1_Init
(
SHA_CTX
*
ctx
)
{
gcry_md_open
(
ctx
,
GCRY_MD_SHA1
,
0
);
return
0
;
}
static
void
SHA1_Update
(
SHA_CTX
*
ctx
,
...
...
@@ -201,9 +206,10 @@ static void SHA1_Final(unsigned char digest[20], SHA_CTX *ctx)
gcry_md_close
(
*
ctx
);
}
static
void
SHA256_Init
(
SHA256_CTX
*
ctx
)
static
int
SHA256_Init
(
SHA256_CTX
*
ctx
)
{
gcry_md_open
(
ctx
,
GCRY_MD_SHA256
,
0
);
return
0
;
}
static
void
SHA256_Update
(
SHA256_CTX
*
ctx
,
...
...
@@ -235,12 +241,13 @@ static void win32_crypto_final(struct win32_crypto_hash *ctx,
CryptReleaseContext
(
ctx
->
hCryptProv
,
0
);
}
static
void
MD5_Init
(
MD5_CTX
*
ctx
)
static
int
MD5_Init
(
MD5_CTX
*
ctx
)
{
if
(
CryptAcquireContext
(
&
ctx
->
hCryptProv
,
NULL
,
NULL
,
PROV_RSA_FULL
,
CRYPT_VERIFYCONTEXT
))
{
CryptCreateHash
(
ctx
->
hCryptProv
,
CALG_MD5
,
0
,
0
,
&
ctx
->
hHash
);
}
return
0
;
}
static
void
MD5_Update
(
MD5_CTX
*
ctx
,
...
...
@@ -255,12 +262,13 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
win32_crypto_final
(
ctx
,
digest
,
16
);
}
static
void
SHA1_Init
(
SHA_CTX
*
ctx
)
static
int
SHA1_Init
(
SHA_CTX
*
ctx
)
{
if
(
CryptAcquireContext
(
&
ctx
->
hCryptProv
,
NULL
,
NULL
,
PROV_RSA_FULL
,
CRYPT_VERIFYCONTEXT
))
{
CryptCreateHash
(
ctx
->
hCryptProv
,
CALG_SHA1
,
0
,
0
,
&
ctx
->
hHash
);
}
return
0
;
}
static
void
SHA1_Update
(
SHA_CTX
*
ctx
,
...
...
@@ -275,12 +283,13 @@ static void SHA1_Final(unsigned char digest[20], SHA_CTX *ctx)
win32_crypto_final
(
ctx
,
digest
,
20
);
}
static
void
SHA256_Init
(
SHA256_CTX
*
ctx
)
static
int
SHA256_Init
(
SHA256_CTX
*
ctx
)
{
if
(
CryptAcquireContext
(
&
ctx
->
hCryptProv
,
NULL
,
NULL
,
PROV_RSA_AES
,
CRYPT_VERIFYCONTEXT
))
{
CryptCreateHash
(
ctx
->
hCryptProv
,
CALG_SHA_256
,
0
,
0
,
&
ctx
->
hHash
);
}
return
0
;
}
static
void
SHA256_Update
(
SHA256_CTX
*
ctx
,
...
...
@@ -374,7 +383,10 @@ digest_context *Curl_digest_init(const digest_params *dparams)
ctxt
->
digest_hash
=
dparams
;
dparams
->
digest_init
(
ctxt
->
digest_hashctx
);
if
(
dparams
->
digest_init
(
ctxt
->
digest_hashctx
)
!=
0
)
{
free
(
ctxt
);
return
NULL
;
}
return
ctxt
;
}
...
...
@@ -425,6 +437,8 @@ static unsigned char hex_to_uint(const char *s)
* Checksum didn't match.
* -1:
* Could not open file; or could not read data from file.
* -2:
* Hash algorithm not available.
*/
static
int
check_hash
(
const
char
*
filename
,
const
metalink_digest_def
*
digest_def
,
...
...
@@ -446,7 +460,15 @@ static int check_hash(const char *filename,
digest_def
->
hash_name
,
strerror
(
errno
));
return
-
1
;
}
dctx
=
Curl_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"
);
close
(
fd
);
return
-
2
;
}
result
=
malloc
(
digest_def
->
dparams
->
digest_resultlen
);
while
(
1
)
{
unsigned
char
buf
[
4096
];
...
...
This diff is collapsed.
Click to expand it.
src/tool_metalink.h
+
3
−
3
View file @
dca8ae5f
...
...
@@ -23,7 +23,7 @@
***************************************************************************/
#include
"tool_setup.h"
typedef
void
(
*
Curl_digest_init_func
)(
void
*
context
);
typedef
int
(
*
Curl_digest_init_func
)(
void
*
context
);
typedef
void
(
*
Curl_digest_update_func
)(
void
*
context
,
const
unsigned
char
*
data
,
unsigned
int
len
);
...
...
@@ -137,8 +137,8 @@ int check_metalink_content_type(const char *content_type);
* -1:
* Could not open file; or could not read data from file.
* -2:
* No checksum in Metalink supported
; or Metalink does not contain
* checksum.
* No checksum in Metalink supported
, hash algorithm not available, or
*
Metalink does not contain
checksum.
*/
int
metalink_check_hash
(
struct
Configurable
*
config
,
metalinkfile
*
mlfile
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment