Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
a223bae5
Unverified
Commit
a223bae5
authored
Jan 03, 2018
by
Edward Thomson
Committed by
GitHub
Jan 03, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4437 from pks-t/pks/openssl-hash-errors
hash: openssl: check return values of SHA1_* functions
parents
399c0b19
ba56f781
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
8 deletions
+31
-8
src/hash/hash_openssl.h
+18
-3
src/streams/openssl.c
+13
-5
No files found.
src/hash/hash_openssl.h
View file @
a223bae5
...
...
@@ -23,21 +23,36 @@ struct git_hash_ctx {
GIT_INLINE
(
int
)
git_hash_init
(
git_hash_ctx
*
ctx
)
{
assert
(
ctx
);
SHA1_Init
(
&
ctx
->
c
);
if
(
SHA1_Init
(
&
ctx
->
c
)
!=
1
)
{
giterr_set
(
GITERR_SHA1
,
"hash_openssl: failed to initialize hash context"
);
return
-
1
;
}
return
0
;
}
GIT_INLINE
(
int
)
git_hash_update
(
git_hash_ctx
*
ctx
,
const
void
*
data
,
size_t
len
)
{
assert
(
ctx
);
SHA1_Update
(
&
ctx
->
c
,
data
,
len
);
if
(
SHA1_Update
(
&
ctx
->
c
,
data
,
len
)
!=
1
)
{
giterr_set
(
GITERR_SHA1
,
"hash_openssl: failed to update hash"
);
return
-
1
;
}
return
0
;
}
GIT_INLINE
(
int
)
git_hash_final
(
git_oid
*
out
,
git_hash_ctx
*
ctx
)
{
assert
(
ctx
);
SHA1_Final
(
out
->
id
,
&
ctx
->
c
);
if
(
SHA1_Final
(
out
->
id
,
&
ctx
->
c
)
!=
1
)
{
giterr_set
(
GITERR_SHA1
,
"hash_openssl: failed to finalize hash"
);
return
-
1
;
}
return
0
;
}
...
...
src/streams/openssl.c
View file @
a223bae5
...
...
@@ -282,8 +282,9 @@ static int ssl_set_error(SSL *ssl, int error)
case
SSL_ERROR_SYSCALL
:
e
=
ERR_get_error
();
if
(
e
>
0
)
{
giterr_set
(
GITERR_NET
,
"SSL error: %s"
,
ERR_error_string
(
e
,
NULL
));
char
errmsg
[
256
];
ERR_error_string_n
(
e
,
errmsg
,
sizeof
(
errmsg
));
giterr_set
(
GITERR_NET
,
"SSL error: %s"
,
errmsg
);
break
;
}
else
if
(
error
<
0
)
{
giterr_set
(
GITERR_OS
,
"SSL error: syscall failure"
);
...
...
@@ -293,10 +294,13 @@ static int ssl_set_error(SSL *ssl, int error)
return
GIT_EEOF
;
break
;
case
SSL_ERROR_SSL
:
{
char
errmsg
[
256
];
e
=
ERR_get_error
();
giterr_set
(
GITERR_NET
,
"SSL error: %s"
,
ERR_error_string
(
e
,
NULL
)
);
ERR_error_string_n
(
e
,
errmsg
,
sizeof
(
errmsg
));
giterr_set
(
GITERR_NET
,
"SSL error: %s"
,
errmsg
);
break
;
}
case
SSL_ERROR_NONE
:
case
SSL_ERROR_ZERO_RETURN
:
default:
...
...
@@ -645,8 +649,12 @@ out_err:
int
git_openssl__set_cert_location
(
const
char
*
file
,
const
char
*
path
)
{
if
(
SSL_CTX_load_verify_locations
(
git__ssl_ctx
,
file
,
path
)
==
0
)
{
char
errmsg
[
256
];
ERR_error_string_n
(
ERR_get_error
(),
errmsg
,
sizeof
(
errmsg
));
giterr_set
(
GITERR_SSL
,
"OpenSSL error: failed to load certificates: %s"
,
ERR_error_string
(
ERR_get_error
(),
NULL
));
errmsg
);
return
-
1
;
}
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment