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
4f5f1127
Commit
4f5f1127
authored
Nov 22, 2020
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transports: use GIT_ASSERT
parent
07a3c992
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
86 additions
and
59 deletions
+86
-59
src/transports/auth_negotiate.c
+10
-3
src/transports/auth_ntlm.c
+8
-4
src/transports/credential.c
+15
-7
src/transports/git.c
+1
-3
src/transports/http.c
+6
-5
src/transports/httpclient.c
+22
-14
src/transports/local.c
+1
-1
src/transports/smart.c
+8
-5
src/transports/ssh.c
+8
-10
src/transports/winhttp.c
+7
-7
No files found.
src/transports/auth_negotiate.c
View file @
4f5f1127
...
@@ -65,7 +65,9 @@ static int negotiate_set_challenge(
...
@@ -65,7 +65,9 @@ static int negotiate_set_challenge(
{
{
http_auth_negotiate_context
*
ctx
=
(
http_auth_negotiate_context
*
)
c
;
http_auth_negotiate_context
*
ctx
=
(
http_auth_negotiate_context
*
)
c
;
assert
(
ctx
&&
ctx
->
configured
&&
challenge
);
GIT_ASSERT_ARG
(
ctx
);
GIT_ASSERT_ARG
(
challenge
);
GIT_ASSERT
(
ctx
->
configured
);
git__free
(
ctx
->
challenge
);
git__free
(
ctx
->
challenge
);
...
@@ -108,7 +110,12 @@ static int negotiate_next_token(
...
@@ -108,7 +110,12 @@ static int negotiate_next_token(
size_t
challenge_len
;
size_t
challenge_len
;
int
error
=
0
;
int
error
=
0
;
assert
(
buf
&&
ctx
&&
ctx
->
configured
&&
cred
&&
cred
->
credtype
==
GIT_CREDENTIAL_DEFAULT
);
GIT_ASSERT_ARG
(
buf
);
GIT_ASSERT_ARG
(
ctx
);
GIT_ASSERT_ARG
(
cred
);
GIT_ASSERT
(
ctx
->
configured
);
GIT_ASSERT
(
cred
->
credtype
==
GIT_CREDENTIAL_DEFAULT
);
if
(
ctx
->
complete
)
if
(
ctx
->
complete
)
return
0
;
return
0
;
...
@@ -202,7 +209,7 @@ static int negotiate_is_complete(git_http_auth_context *c)
...
@@ -202,7 +209,7 @@ static int negotiate_is_complete(git_http_auth_context *c)
{
{
http_auth_negotiate_context
*
ctx
=
(
http_auth_negotiate_context
*
)
c
;
http_auth_negotiate_context
*
ctx
=
(
http_auth_negotiate_context
*
)
c
;
assert
(
ctx
);
GIT_ASSERT_ARG
(
ctx
);
return
(
ctx
->
complete
==
1
);
return
(
ctx
->
complete
==
1
);
}
}
...
...
src/transports/auth_ntlm.c
View file @
4f5f1127
...
@@ -29,7 +29,8 @@ static int ntlm_set_challenge(
...
@@ -29,7 +29,8 @@ static int ntlm_set_challenge(
{
{
http_auth_ntlm_context
*
ctx
=
(
http_auth_ntlm_context
*
)
c
;
http_auth_ntlm_context
*
ctx
=
(
http_auth_ntlm_context
*
)
c
;
assert
(
ctx
&&
challenge
);
GIT_ASSERT_ARG
(
ctx
);
GIT_ASSERT_ARG
(
challenge
);
git__free
(
ctx
->
challenge
);
git__free
(
ctx
->
challenge
);
...
@@ -46,7 +47,7 @@ static int ntlm_set_credentials(http_auth_ntlm_context *ctx, git_credential *_cr
...
@@ -46,7 +47,7 @@ static int ntlm_set_credentials(http_auth_ntlm_context *ctx, git_credential *_cr
char
*
domain
=
NULL
,
*
domainuser
=
NULL
;
char
*
domain
=
NULL
,
*
domainuser
=
NULL
;
int
error
=
0
;
int
error
=
0
;
assert
(
_cred
->
credtype
==
GIT_CREDENTIAL_USERPASS_PLAINTEXT
);
GIT_ASSERT
(
_cred
->
credtype
==
GIT_CREDENTIAL_USERPASS_PLAINTEXT
);
cred
=
(
git_credential_userpass_plaintext
*
)
_cred
;
cred
=
(
git_credential_userpass_plaintext
*
)
_cred
;
if
((
sep
=
strchr
(
cred
->
username
,
'\\'
))
!=
NULL
)
{
if
((
sep
=
strchr
(
cred
->
username
,
'\\'
))
!=
NULL
)
{
...
@@ -86,7 +87,10 @@ static int ntlm_next_token(
...
@@ -86,7 +87,10 @@ static int ntlm_next_token(
size_t
challenge_len
,
msg_len
;
size_t
challenge_len
,
msg_len
;
int
error
=
-
1
;
int
error
=
-
1
;
assert
(
buf
&&
ctx
&&
ctx
->
ntlm
);
GIT_ASSERT_ARG
(
buf
);
GIT_ASSERT_ARG
(
ctx
);
GIT_ASSERT
(
ctx
->
ntlm
);
challenge_len
=
ctx
->
challenge
?
strlen
(
ctx
->
challenge
)
:
0
;
challenge_len
=
ctx
->
challenge
?
strlen
(
ctx
->
challenge
)
:
0
;
...
@@ -162,7 +166,7 @@ static int ntlm_is_complete(git_http_auth_context *c)
...
@@ -162,7 +166,7 @@ static int ntlm_is_complete(git_http_auth_context *c)
{
{
http_auth_ntlm_context
*
ctx
=
(
http_auth_ntlm_context
*
)
c
;
http_auth_ntlm_context
*
ctx
=
(
http_auth_ntlm_context
*
)
c
;
assert
(
ctx
);
GIT_ASSERT_ARG
(
ctx
);
return
(
ctx
->
complete
==
true
);
return
(
ctx
->
complete
==
true
);
}
}
...
...
src/transports/credential.c
View file @
4f5f1127
...
@@ -85,7 +85,9 @@ int git_credential_userpass_plaintext_new(
...
@@ -85,7 +85,9 @@ int git_credential_userpass_plaintext_new(
{
{
git_credential_userpass_plaintext
*
c
;
git_credential_userpass_plaintext
*
c
;
assert
(
cred
&&
username
&&
password
);
GIT_ASSERT_ARG
(
cred
);
GIT_ASSERT_ARG
(
username
);
GIT_ASSERT_ARG
(
password
);
c
=
git__malloc
(
sizeof
(
git_credential_userpass_plaintext
));
c
=
git__malloc
(
sizeof
(
git_credential_userpass_plaintext
));
GIT_ERROR_CHECK_ALLOC
(
c
);
GIT_ERROR_CHECK_ALLOC
(
c
);
...
@@ -233,7 +235,9 @@ static int git_credential_ssh_key_type_new(
...
@@ -233,7 +235,9 @@ static int git_credential_ssh_key_type_new(
{
{
git_credential_ssh_key
*
c
;
git_credential_ssh_key
*
c
;
assert
(
username
&&
cred
&&
privatekey
);
GIT_ASSERT_ARG
(
username
);
GIT_ASSERT_ARG
(
cred
);
GIT_ASSERT_ARG
(
privatekey
);
c
=
git__calloc
(
1
,
sizeof
(
git_credential_ssh_key
));
c
=
git__calloc
(
1
,
sizeof
(
git_credential_ssh_key
));
GIT_ERROR_CHECK_ALLOC
(
c
);
GIT_ERROR_CHECK_ALLOC
(
c
);
...
@@ -269,7 +273,9 @@ int git_credential_ssh_interactive_new(
...
@@ -269,7 +273,9 @@ int git_credential_ssh_interactive_new(
{
{
git_credential_ssh_interactive
*
c
;
git_credential_ssh_interactive
*
c
;
assert
(
out
&&
username
&&
prompt_callback
);
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
username
);
GIT_ASSERT_ARG
(
prompt_callback
);
c
=
git__calloc
(
1
,
sizeof
(
git_credential_ssh_interactive
));
c
=
git__calloc
(
1
,
sizeof
(
git_credential_ssh_interactive
));
GIT_ERROR_CHECK_ALLOC
(
c
);
GIT_ERROR_CHECK_ALLOC
(
c
);
...
@@ -290,7 +296,8 @@ int git_credential_ssh_interactive_new(
...
@@ -290,7 +296,8 @@ int git_credential_ssh_interactive_new(
int
git_credential_ssh_key_from_agent
(
git_credential
**
cred
,
const
char
*
username
)
{
int
git_credential_ssh_key_from_agent
(
git_credential
**
cred
,
const
char
*
username
)
{
git_credential_ssh_key
*
c
;
git_credential_ssh_key
*
c
;
assert
(
username
&&
cred
);
GIT_ASSERT_ARG
(
username
);
GIT_ASSERT_ARG
(
cred
);
c
=
git__calloc
(
1
,
sizeof
(
git_credential_ssh_key
));
c
=
git__calloc
(
1
,
sizeof
(
git_credential_ssh_key
));
GIT_ERROR_CHECK_ALLOC
(
c
);
GIT_ERROR_CHECK_ALLOC
(
c
);
...
@@ -317,7 +324,8 @@ int git_credential_ssh_custom_new(
...
@@ -317,7 +324,8 @@ int git_credential_ssh_custom_new(
{
{
git_credential_ssh_custom
*
c
;
git_credential_ssh_custom
*
c
;
assert
(
username
&&
cred
);
GIT_ASSERT_ARG
(
username
);
GIT_ASSERT_ARG
(
cred
);
c
=
git__calloc
(
1
,
sizeof
(
git_credential_ssh_custom
));
c
=
git__calloc
(
1
,
sizeof
(
git_credential_ssh_custom
));
GIT_ERROR_CHECK_ALLOC
(
c
);
GIT_ERROR_CHECK_ALLOC
(
c
);
...
@@ -347,7 +355,7 @@ int git_credential_default_new(git_credential **cred)
...
@@ -347,7 +355,7 @@ int git_credential_default_new(git_credential **cred)
{
{
git_credential_default
*
c
;
git_credential_default
*
c
;
assert
(
cred
);
GIT_ASSERT_ARG
(
cred
);
c
=
git__calloc
(
1
,
sizeof
(
git_credential_default
));
c
=
git__calloc
(
1
,
sizeof
(
git_credential_default
));
GIT_ERROR_CHECK_ALLOC
(
c
);
GIT_ERROR_CHECK_ALLOC
(
c
);
...
@@ -364,7 +372,7 @@ int git_credential_username_new(git_credential **cred, const char *username)
...
@@ -364,7 +372,7 @@ int git_credential_username_new(git_credential **cred, const char *username)
git_credential_username
*
c
;
git_credential_username
*
c
;
size_t
len
,
allocsize
;
size_t
len
,
allocsize
;
assert
(
cred
);
GIT_ASSERT_ARG
(
cred
);
len
=
strlen
(
username
);
len
=
strlen
(
username
);
...
...
src/transports/git.c
View file @
4f5f1127
...
@@ -327,7 +327,7 @@ static int _git_close(git_smart_subtransport *subtransport)
...
@@ -327,7 +327,7 @@ static int _git_close(git_smart_subtransport *subtransport)
{
{
git_subtransport
*
t
=
(
git_subtransport
*
)
subtransport
;
git_subtransport
*
t
=
(
git_subtransport
*
)
subtransport
;
assert
(
!
t
->
current_stream
);
GIT_ASSERT
(
!
t
->
current_stream
);
GIT_UNUSED
(
t
);
GIT_UNUSED
(
t
);
...
@@ -338,8 +338,6 @@ static void _git_free(git_smart_subtransport *subtransport)
...
@@ -338,8 +338,6 @@ static void _git_free(git_smart_subtransport *subtransport)
{
{
git_subtransport
*
t
=
(
git_subtransport
*
)
subtransport
;
git_subtransport
*
t
=
(
git_subtransport
*
)
subtransport
;
assert
(
!
t
->
current_stream
);
git__free
(
t
);
git__free
(
t
);
}
}
...
...
src/transports/http.c
View file @
4f5f1127
...
@@ -416,7 +416,7 @@ static int http_stream_read(
...
@@ -416,7 +416,7 @@ static int http_stream_read(
goto
done
;
goto
done
;
}
}
assert
(
stream
->
state
==
HTTP_STATE_RECEIVING_RESPONSE
);
GIT_ASSERT
(
stream
->
state
==
HTTP_STATE_RECEIVING_RESPONSE
);
error
=
git_http_client_read_body
(
transport
->
http_client
,
buffer
,
buffer_size
);
error
=
git_http_client_read_body
(
transport
->
http_client
,
buffer
,
buffer_size
);
...
@@ -554,7 +554,7 @@ static int http_stream_write(
...
@@ -554,7 +554,7 @@ static int http_stream_write(
goto
done
;
goto
done
;
}
}
assert
(
stream
->
state
==
HTTP_STATE_SENDING_REQUEST
);
GIT_ASSERT
(
stream
->
state
==
HTTP_STATE_SENDING_REQUEST
);
error
=
git_http_client_send_body
(
transport
->
http_client
,
buffer
,
len
);
error
=
git_http_client_send_body
(
transport
->
http_client
,
buffer
,
len
);
...
@@ -588,7 +588,7 @@ static int http_stream_read_response(
...
@@ -588,7 +588,7 @@ static int http_stream_read_response(
(
error
=
handle_response
(
&
complete
,
stream
,
&
response
,
false
))
<
0
)
(
error
=
handle_response
(
&
complete
,
stream
,
&
response
,
false
))
<
0
)
goto
done
;
goto
done
;
assert
(
complete
);
GIT_ASSERT
(
complete
);
stream
->
state
=
HTTP_STATE_RECEIVING_RESPONSE
;
stream
->
state
=
HTTP_STATE_RECEIVING_RESPONSE
;
}
}
...
@@ -637,7 +637,8 @@ static int http_action(
...
@@ -637,7 +637,8 @@ static int http_action(
const
http_service
*
service
;
const
http_service
*
service
;
int
error
;
int
error
;
assert
(
out
&&
t
);
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
t
);
*
out
=
NULL
;
*
out
=
NULL
;
...
@@ -720,7 +721,7 @@ int git_smart_subtransport_http(git_smart_subtransport **out, git_transport *own
...
@@ -720,7 +721,7 @@ int git_smart_subtransport_http(git_smart_subtransport **out, git_transport *own
GIT_UNUSED
(
param
);
GIT_UNUSED
(
param
);
assert
(
out
);
GIT_ASSERT_ARG
(
out
);
transport
=
git__calloc
(
sizeof
(
http_subtransport
),
1
);
transport
=
git__calloc
(
sizeof
(
http_subtransport
),
1
);
GIT_ERROR_CHECK_ALLOC
(
transport
);
GIT_ERROR_CHECK_ALLOC
(
transport
);
...
...
src/transports/httpclient.c
View file @
4f5f1127
...
@@ -145,7 +145,8 @@ bool git_http_response_is_redirect(git_http_response *response)
...
@@ -145,7 +145,8 @@ bool git_http_response_is_redirect(git_http_response *response)
void
git_http_response_dispose
(
git_http_response
*
response
)
void
git_http_response_dispose
(
git_http_response
*
response
)
{
{
assert
(
response
);
if
(
!
response
)
return
;
git__free
(
response
->
content_type
);
git__free
(
response
->
content_type
);
git__free
(
response
->
location
);
git__free
(
response
->
location
);
...
@@ -399,7 +400,7 @@ static int on_body(http_parser *parser, const char *buf, size_t len)
...
@@ -399,7 +400,7 @@ static int on_body(http_parser *parser, const char *buf, size_t len)
return
0
;
return
0
;
}
}
assert
(
ctx
->
output_size
>=
ctx
->
output_written
);
GIT_ASSERT
(
ctx
->
output_size
>=
ctx
->
output_written
);
max_len
=
min
(
ctx
->
output_size
-
ctx
->
output_written
,
len
);
max_len
=
min
(
ctx
->
output_size
-
ctx
->
output_written
,
len
);
max_len
=
min
(
max_len
,
INT_MAX
);
max_len
=
min
(
max_len
,
INT_MAX
);
...
@@ -665,7 +666,8 @@ static int generate_request(
...
@@ -665,7 +666,8 @@ static int generate_request(
size_t
i
;
size_t
i
;
int
error
;
int
error
;
assert
(
client
&&
request
);
GIT_ASSERT_ARG
(
client
);
GIT_ASSERT_ARG
(
request
);
git_buf_clear
(
&
client
->
request_msg
);
git_buf_clear
(
&
client
->
request_msg
);
buf
=
&
client
->
request_msg
;
buf
=
&
client
->
request_msg
;
...
@@ -842,7 +844,10 @@ static int setup_hosts(
...
@@ -842,7 +844,10 @@ static int setup_hosts(
{
{
int
ret
,
diff
=
0
;
int
ret
,
diff
=
0
;
assert
(
client
&&
request
&&
request
->
url
);
GIT_ASSERT_ARG
(
client
);
GIT_ASSERT_ARG
(
request
);
GIT_ASSERT
(
request
->
url
);
if
((
ret
=
server_setup_from_url
(
&
client
->
server
,
request
->
url
))
<
0
)
if
((
ret
=
server_setup_from_url
(
&
client
->
server
,
request
->
url
))
<
0
)
return
ret
;
return
ret
;
...
@@ -922,7 +927,7 @@ static int proxy_connect(
...
@@ -922,7 +927,7 @@ static int proxy_connect(
(
error
=
git_http_client_skip_body
(
client
))
<
0
)
(
error
=
git_http_client_skip_body
(
client
))
<
0
)
goto
done
;
goto
done
;
assert
(
client
->
state
==
DONE
);
GIT_ASSERT
(
client
->
state
==
DONE
);
if
(
response
.
status
==
GIT_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED
)
{
if
(
response
.
status
==
GIT_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED
)
{
save_early_response
(
client
,
&
response
);
save_early_response
(
client
,
&
response
);
...
@@ -1137,7 +1142,7 @@ GIT_INLINE(int) client_read_and_parse(git_http_client *client)
...
@@ -1137,7 +1142,7 @@ GIT_INLINE(int) client_read_and_parse(git_http_client *client)
* final byte when paused in a callback. Consume that byte.
* final byte when paused in a callback. Consume that byte.
* https://github.com/nodejs/http-parser/issues/97
* https://github.com/nodejs/http-parser/issues/97
*/
*/
assert
(
client
->
read_buf
.
size
>
parsed_len
);
GIT_ASSERT
(
client
->
read_buf
.
size
>
parsed_len
);
http_parser_pause
(
parser
,
0
);
http_parser_pause
(
parser
,
0
);
...
@@ -1215,7 +1220,8 @@ int git_http_client_send_request(
...
@@ -1215,7 +1220,8 @@ int git_http_client_send_request(
git_http_response
response
=
{
0
};
git_http_response
response
=
{
0
};
int
error
=
-
1
;
int
error
=
-
1
;
assert
(
client
&&
request
);
GIT_ASSERT_ARG
(
client
);
GIT_ASSERT_ARG
(
request
);
/* If the client did not finish reading, clean up the stream. */
/* If the client did not finish reading, clean up the stream. */
if
(
client
->
state
==
READING_BODY
)
if
(
client
->
state
==
READING_BODY
)
...
@@ -1286,7 +1292,7 @@ int git_http_client_send_body(
...
@@ -1286,7 +1292,7 @@ int git_http_client_send_body(
git_buf
hdr
=
GIT_BUF_INIT
;
git_buf
hdr
=
GIT_BUF_INIT
;
int
error
;
int
error
;
assert
(
client
);
GIT_ASSERT_ARG
(
client
);
/* If we're waiting for proxy auth, don't sending more requests. */
/* If we're waiting for proxy auth, don't sending more requests. */
if
(
client
->
state
==
HAS_EARLY_RESPONSE
)
if
(
client
->
state
==
HAS_EARLY_RESPONSE
)
...
@@ -1303,7 +1309,7 @@ int git_http_client_send_body(
...
@@ -1303,7 +1309,7 @@ int git_http_client_send_body(
server
=
&
client
->
server
;
server
=
&
client
->
server
;
if
(
client
->
request_body_len
)
{
if
(
client
->
request_body_len
)
{
assert
(
buffer_len
<=
client
->
request_body_remain
);
GIT_ASSERT
(
buffer_len
<=
client
->
request_body_remain
);
if
((
error
=
stream_write
(
server
,
buffer
,
buffer_len
))
<
0
)
if
((
error
=
stream_write
(
server
,
buffer
,
buffer_len
))
<
0
)
goto
done
;
goto
done
;
...
@@ -1326,7 +1332,8 @@ static int complete_request(git_http_client *client)
...
@@ -1326,7 +1332,8 @@ static int complete_request(git_http_client *client)
{
{
int
error
=
0
;
int
error
=
0
;
assert
(
client
&&
client
->
state
==
SENDING_BODY
);
GIT_ASSERT_ARG
(
client
);
GIT_ASSERT
(
client
->
state
==
SENDING_BODY
);
if
(
client
->
request_body_len
&&
client
->
request_body_remain
)
{
if
(
client
->
request_body_len
&&
client
->
request_body_remain
)
{
git_error_set
(
GIT_ERROR_HTTP
,
"truncated write"
);
git_error_set
(
GIT_ERROR_HTTP
,
"truncated write"
);
...
@@ -1346,7 +1353,8 @@ int git_http_client_read_response(
...
@@ -1346,7 +1353,8 @@ int git_http_client_read_response(
http_parser_context
parser_context
=
{
0
};
http_parser_context
parser_context
=
{
0
};
int
error
;
int
error
;
assert
(
response
&&
client
);
GIT_ASSERT_ARG
(
response
);
GIT_ASSERT_ARG
(
client
);
if
(
client
->
state
==
SENDING_BODY
)
{
if
(
client
->
state
==
SENDING_BODY
)
{
if
((
error
=
complete_request
(
client
))
<
0
)
if
((
error
=
complete_request
(
client
))
<
0
)
...
@@ -1386,7 +1394,7 @@ int git_http_client_read_response(
...
@@ -1386,7 +1394,7 @@ int git_http_client_read_response(
goto
done
;
goto
done
;
}
}
assert
(
client
->
state
==
READING_BODY
||
client
->
state
==
DONE
);
GIT_ASSERT
(
client
->
state
==
READING_BODY
||
client
->
state
==
DONE
);
done
:
done
:
git_buf_dispose
(
&
parser_context
.
parse_header_name
);
git_buf_dispose
(
&
parser_context
.
parse_header_name
);
...
@@ -1439,7 +1447,7 @@ int git_http_client_read_body(
...
@@ -1439,7 +1447,7 @@ int git_http_client_read_body(
break
;
break
;
}
}
assert
(
parser_context
.
output_written
<=
INT_MAX
);
GIT_ASSERT
(
parser_context
.
output_written
<=
INT_MAX
);
error
=
(
int
)
parser_context
.
output_written
;
error
=
(
int
)
parser_context
.
output_written
;
done
:
done
:
...
@@ -1493,7 +1501,7 @@ int git_http_client_new(
...
@@ -1493,7 +1501,7 @@ int git_http_client_new(
{
{
git_http_client
*
client
;
git_http_client
*
client
;
assert
(
out
);
GIT_ASSERT_ARG
(
out
);
client
=
git__calloc
(
1
,
sizeof
(
git_http_client
));
client
=
git__calloc
(
1
,
sizeof
(
git_http_client
));
GIT_ERROR_CHECK_ALLOC
(
client
);
GIT_ERROR_CHECK_ALLOC
(
client
);
...
...
src/transports/local.c
View file @
4f5f1127
...
@@ -158,7 +158,7 @@ static int store_refs(transport_local *t)
...
@@ -158,7 +158,7 @@ static int store_refs(transport_local *t)
git_remote_head
*
head
;
git_remote_head
*
head
;
git_strarray
ref_names
=
{
0
};
git_strarray
ref_names
=
{
0
};
assert
(
t
);
GIT_ASSERT_ARG
(
t
);
if
(
git_reference_list
(
&
ref_names
,
t
->
repo
)
<
0
)
if
(
git_reference_list
(
&
ref_names
,
t
->
repo
)
<
0
)
goto
on_error
;
goto
on_error
;
...
...
src/transports/smart.c
View file @
4f5f1127
...
@@ -18,7 +18,7 @@ static int git_smart__recv_cb(gitno_buffer *buf)
...
@@ -18,7 +18,7 @@ static int git_smart__recv_cb(gitno_buffer *buf)
size_t
old_len
,
bytes_read
;
size_t
old_len
,
bytes_read
;
int
error
;
int
error
;
assert
(
t
->
current_stream
);
GIT_ASSERT
(
t
->
current_stream
);
old_len
=
buf
->
offset
;
old_len
=
buf
->
offset
;
...
@@ -346,7 +346,7 @@ int git_smart__negotiation_step(git_transport *transport, void *data, size_t len
...
@@ -346,7 +346,7 @@ int git_smart__negotiation_step(git_transport *transport, void *data, size_t len
return
error
;
return
error
;
/* If this is a stateful implementation, the stream we get back should be the same */
/* If this is a stateful implementation, the stream we get back should be the same */
assert
(
t
->
rpc
||
t
->
current_stream
==
stream
);
GIT_ASSERT
(
t
->
rpc
||
t
->
current_stream
==
stream
);
/* Save off the current stream (i.e. socket) that we are working with */
/* Save off the current stream (i.e. socket) that we are working with */
t
->
current_stream
=
stream
;
t
->
current_stream
=
stream
;
...
@@ -375,7 +375,7 @@ int git_smart__get_push_stream(transport_smart *t, git_smart_subtransport_stream
...
@@ -375,7 +375,7 @@ int git_smart__get_push_stream(transport_smart *t, git_smart_subtransport_stream
return
error
;
return
error
;
/* If this is a stateful implementation, the stream we get back should be the same */
/* If this is a stateful implementation, the stream we get back should be the same */
assert
(
t
->
rpc
||
t
->
current_stream
==
*
stream
);
GIT_ASSERT
(
t
->
rpc
||
t
->
current_stream
==
*
stream
);
/* Save off the current stream (i.e. socket) that we are working with */
/* Save off the current stream (i.e. socket) that we are working with */
t
->
current_stream
=
*
stream
;
t
->
current_stream
=
*
stream
;
...
@@ -481,7 +481,9 @@ int git_transport_smart_certificate_check(git_transport *transport, git_cert *ce
...
@@ -481,7 +481,9 @@ int git_transport_smart_certificate_check(git_transport *transport, git_cert *ce
{
{
transport_smart
*
t
=
GIT_CONTAINER_OF
(
transport
,
transport_smart
,
parent
);
transport_smart
*
t
=
GIT_CONTAINER_OF
(
transport
,
transport_smart
,
parent
);
assert
(
transport
&&
cert
&&
hostname
);
GIT_ASSERT_ARG
(
transport
);
GIT_ASSERT_ARG
(
cert
);
GIT_ASSERT_ARG
(
hostname
);
if
(
!
t
->
certificate_check_cb
)
if
(
!
t
->
certificate_check_cb
)
return
GIT_PASSTHROUGH
;
return
GIT_PASSTHROUGH
;
...
@@ -493,7 +495,8 @@ int git_transport_smart_credentials(git_credential **out, git_transport *transpo
...
@@ -493,7 +495,8 @@ int git_transport_smart_credentials(git_credential **out, git_transport *transpo
{
{
transport_smart
*
t
=
GIT_CONTAINER_OF
(
transport
,
transport_smart
,
parent
);
transport_smart
*
t
=
GIT_CONTAINER_OF
(
transport
,
transport_smart
,
parent
);
assert
(
out
&&
transport
);
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
transport
);
if
(
!
t
->
cred_acquire_cb
)
if
(
!
t
->
cred_acquire_cb
)
return
GIT_PASSTHROUGH
;
return
GIT_PASSTHROUGH
;
...
...
src/transports/ssh.c
View file @
4f5f1127
...
@@ -238,7 +238,7 @@ static int ssh_stream_alloc(
...
@@ -238,7 +238,7 @@ static int ssh_stream_alloc(
{
{
ssh_stream
*
s
;
ssh_stream
*
s
;
assert
(
stream
);
GIT_ASSERT_ARG
(
stream
);
s
=
git__calloc
(
sizeof
(
ssh_stream
),
1
);
s
=
git__calloc
(
sizeof
(
ssh_stream
),
1
);
GIT_ERROR_CHECK_ALLOC
(
s
);
GIT_ERROR_CHECK_ALLOC
(
s
);
...
@@ -404,8 +404,8 @@ static int _git_ssh_authenticate_session(
...
@@ -404,8 +404,8 @@ static int _git_ssh_authenticate_session(
case
GIT_CREDENTIAL_SSH_MEMORY
:
{
case
GIT_CREDENTIAL_SSH_MEMORY
:
{
git_credential_ssh_key
*
c
=
(
git_credential_ssh_key
*
)
cred
;
git_credential_ssh_key
*
c
=
(
git_credential_ssh_key
*
)
cred
;
assert
(
c
->
username
);
GIT_ASSERT
(
c
->
username
);
assert
(
c
->
privatekey
);
GIT_ASSERT
(
c
->
privatekey
);
rc
=
libssh2_userauth_publickey_frommemory
(
rc
=
libssh2_userauth_publickey_frommemory
(
session
,
session
,
...
@@ -483,7 +483,7 @@ static int _git_ssh_session_create(
...
@@ -483,7 +483,7 @@ static int _git_ssh_session_create(
LIBSSH2_SESSION
*
s
;
LIBSSH2_SESSION
*
s
;
git_socket_stream
*
socket
=
GIT_CONTAINER_OF
(
io
,
git_socket_stream
,
parent
);
git_socket_stream
*
socket
=
GIT_CONTAINER_OF
(
io
,
git_socket_stream
,
parent
);
assert
(
session
);
GIT_ASSERT_ARG
(
session
);
s
=
libssh2_session_init
();
s
=
libssh2_session_init
();
if
(
!
s
)
{
if
(
!
s
)
{
...
@@ -772,7 +772,7 @@ static int _ssh_close(git_smart_subtransport *subtransport)
...
@@ -772,7 +772,7 @@ static int _ssh_close(git_smart_subtransport *subtransport)
{
{
ssh_subtransport
*
t
=
GIT_CONTAINER_OF
(
subtransport
,
ssh_subtransport
,
parent
);
ssh_subtransport
*
t
=
GIT_CONTAINER_OF
(
subtransport
,
ssh_subtransport
,
parent
);
assert
(
!
t
->
current_stream
);
GIT_ASSERT
(
!
t
->
current_stream
);
GIT_UNUSED
(
t
);
GIT_UNUSED
(
t
);
...
@@ -783,8 +783,6 @@ static void _ssh_free(git_smart_subtransport *subtransport)
...
@@ -783,8 +783,6 @@ static void _ssh_free(git_smart_subtransport *subtransport)
{
{
ssh_subtransport
*
t
=
GIT_CONTAINER_OF
(
subtransport
,
ssh_subtransport
,
parent
);
ssh_subtransport
*
t
=
GIT_CONTAINER_OF
(
subtransport
,
ssh_subtransport
,
parent
);
assert
(
!
t
->
current_stream
);
git__free
(
t
->
cmd_uploadpack
);
git__free
(
t
->
cmd_uploadpack
);
git__free
(
t
->
cmd_receivepack
);
git__free
(
t
->
cmd_receivepack
);
git__free
(
t
);
git__free
(
t
);
...
@@ -849,7 +847,7 @@ int git_smart_subtransport_ssh(
...
@@ -849,7 +847,7 @@ int git_smart_subtransport_ssh(
#ifdef GIT_SSH
#ifdef GIT_SSH
ssh_subtransport
*
t
;
ssh_subtransport
*
t
;
assert
(
out
);
GIT_ASSERT_ARG
(
out
);
GIT_UNUSED
(
param
);
GIT_UNUSED
(
param
);
...
@@ -867,7 +865,7 @@ int git_smart_subtransport_ssh(
...
@@ -867,7 +865,7 @@ int git_smart_subtransport_ssh(
GIT_UNUSED
(
owner
);
GIT_UNUSED
(
owner
);
GIT_UNUSED
(
param
);
GIT_UNUSED
(
param
);
assert
(
out
);
GIT_ASSERT_ARG
(
out
);
*
out
=
NULL
;
*
out
=
NULL
;
git_error_set
(
GIT_ERROR_INVALID
,
"cannot create SSH transport. Library was built without SSH support"
);
git_error_set
(
GIT_ERROR_INVALID
,
"cannot create SSH transport. Library was built without SSH support"
);
...
@@ -911,7 +909,7 @@ int git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *p
...
@@ -911,7 +909,7 @@ int git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *p
GIT_UNUSED
(
owner
);
GIT_UNUSED
(
owner
);
GIT_UNUSED
(
payload
);
GIT_UNUSED
(
payload
);
assert
(
out
);
GIT_ASSERT_ARG
(
out
);
*
out
=
NULL
;
*
out
=
NULL
;
git_error_set
(
GIT_ERROR_INVALID
,
"cannot create SSH transport. Library was built without SSH support"
);
git_error_set
(
GIT_ERROR_INVALID
,
"cannot create SSH transport. Library was built without SSH support"
);
...
...
src/transports/winhttp.c
View file @
4f5f1127
...
@@ -1003,7 +1003,7 @@ replay:
...
@@ -1003,7 +1003,7 @@ replay:
}
}
if
(
s
->
chunked
)
{
if
(
s
->
chunked
)
{
assert
(
s
->
verb
==
post_verb
);
GIT_ASSERT
(
s
->
verb
==
post_verb
);
/* Flush, if necessary */
/* Flush, if necessary */
if
(
s
->
chunk_buffer_len
>
0
&&
if
(
s
->
chunk_buffer_len
>
0
&&
...
@@ -1054,7 +1054,7 @@ replay:
...
@@ -1054,7 +1054,7 @@ replay:
}
}
len
-=
bytes_read
;
len
-=
bytes_read
;
assert
(
bytes_read
==
bytes_written
);
GIT_ASSERT
(
bytes_read
==
bytes_written
);
}
}
git__free
(
buffer
);
git__free
(
buffer
);
...
@@ -1166,7 +1166,7 @@ replay:
...
@@ -1166,7 +1166,7 @@ replay:
if
(
error
<
0
)
{
if
(
error
<
0
)
{
return
error
;
return
error
;
}
else
if
(
!
error
)
{
}
else
if
(
!
error
)
{
assert
(
t
->
server
.
cred
);
GIT_ASSERT
(
t
->
server
.
cred
);
winhttp_stream_close
(
s
);
winhttp_stream_close
(
s
);
goto
replay
;
goto
replay
;
}
}
...
@@ -1180,7 +1180,7 @@ replay:
...
@@ -1180,7 +1180,7 @@ replay:
if
(
error
<
0
)
{
if
(
error
<
0
)
{
return
error
;
return
error
;
}
else
if
(
!
error
)
{
}
else
if
(
!
error
)
{
assert
(
t
->
proxy
.
cred
);
GIT_ASSERT
(
t
->
proxy
.
cred
);
winhttp_stream_close
(
s
);
winhttp_stream_close
(
s
);
goto
replay
;
goto
replay
;
}
}
...
@@ -1266,7 +1266,7 @@ static int winhttp_stream_write_single(
...
@@ -1266,7 +1266,7 @@ static int winhttp_stream_write_single(
return
-
1
;
return
-
1
;
}
}
assert
((
DWORD
)
len
==
bytes_written
);
GIT_ASSERT
((
DWORD
)
len
==
bytes_written
);
return
0
;
return
0
;
}
}
...
@@ -1365,7 +1365,7 @@ static int winhttp_stream_write_buffered(
...
@@ -1365,7 +1365,7 @@ static int winhttp_stream_write_buffered(
return
-
1
;
return
-
1
;
}
}
assert
((
DWORD
)
len
==
bytes_written
);
GIT_ASSERT
((
DWORD
)
len
==
bytes_written
);
s
->
post_body_len
+=
bytes_written
;
s
->
post_body_len
+=
bytes_written
;
...
@@ -1572,7 +1572,7 @@ static int winhttp_action(
...
@@ -1572,7 +1572,7 @@ static int winhttp_action(
break
;
break
;
default:
default:
assert
(
0
);
GIT_ASSERT
(
0
);
}
}
if
(
!
ret
)
if
(
!
ret
)
...
...
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