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
6995b18a
Commit
6995b18a
authored
Jun 12, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3208 from git-up/secure_transport
Fixed some Secure Transport issues on OS X
parents
4ce58244
6d0a0aca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
20 deletions
+36
-20
src/stransport_stream.c
+36
-20
No files found.
src/stransport_stream.c
View file @
6995b18a
...
...
@@ -110,19 +110,26 @@ int stransport_certificate(git_cert **out, git_stream *stream)
return
0
;
}
/*
* Contrary to typical network IO callbacks, Secure Transport write callback is
* expected to write *all* passed data, not just as much as it can, and any
* other case would be considered a failure.
*
* This behavior is actually not specified in the Apple documentation, but is
* required for things to work correctly (and incidentally, that's also how
* Apple implements it in its projects at opensource.apple.com).
*
* Libgit2 streams happen to already have this very behavior so this is just
* passthrough.
*/
static
OSStatus
write_cb
(
SSLConnectionRef
conn
,
const
void
*
data
,
size_t
*
len
)
{
git_stream
*
io
=
(
git_stream
*
)
conn
;
ssize_t
ret
;
ret
=
git_stream_write
(
io
,
data
,
*
len
,
0
);
if
(
ret
<
0
)
{
*
len
=
0
;
return
-
1
;
if
(
git_stream_write
(
io
,
data
,
*
len
,
0
)
<
0
)
{
return
-
36
;
/* "ioErr" from MacErrors.h which is not available on iOS */
}
*
len
=
ret
;
return
noErr
;
}
...
...
@@ -141,29 +148,38 @@ ssize_t stransport_write(git_stream *stream, const char *data, size_t len, int f
return
processed
;
}
/*
* Contrary to typical network IO callbacks, Secure Transport read callback is
* expected to read *exactly* the requested number of bytes, not just as much
* as it can, and any other case would be considered a failure.
*
* This behavior is actually not specified in the Apple documentation, but is
* required for things to work correctly (and incidentally, that's also how
* Apple implements it in its projects at opensource.apple.com).
*/
static
OSStatus
read_cb
(
SSLConnectionRef
conn
,
void
*
data
,
size_t
*
len
)
{
git_stream
*
io
=
(
git_stream
*
)
conn
;
OSStatus
error
=
noErr
;
size_t
off
=
0
;
ssize_t
ret
;
size_t
left
,
requested
;
requested
=
left
=
*
len
;
do
{
ret
=
git_stream_read
(
io
,
data
+
(
requested
-
left
),
left
);
ret
=
git_stream_read
(
io
,
data
+
off
,
*
len
-
off
);
if
(
ret
<
0
)
{
*
len
=
0
;
return
-
1
;
error
=
-
36
;
/* "ioErr" from MacErrors.h which is not available on iOS */
break
;
}
if
(
ret
==
0
)
{
error
=
errSSLClosedGraceful
;
break
;
}
left
-=
ret
;
}
while
(
left
);
*
len
=
requested
;
if
(
ret
==
0
)
return
errSSLClosedGraceful
;
off
+=
ret
;
}
while
(
off
<
*
len
);
return
noErr
;
*
len
=
off
;
return
error
;
}
ssize_t
stransport_read
(
git_stream
*
stream
,
void
*
data
,
size_t
len
)
...
...
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