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
05816a98
Commit
05816a98
authored
Apr 05, 2020
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
netops: use GIT_ASSERT
parent
ea7c807a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
7 deletions
+14
-7
src/netops.c
+5
-3
src/netops.h
+1
-1
src/transports/smart_protocol.c
+8
-3
No files found.
src/netops.c
View file @
05816a98
...
...
@@ -61,18 +61,20 @@ void gitno_buffer_setup_fromstream(git_stream *st, gitno_buffer *buf, char *data
}
/* Consume up to ptr and move the rest of the buffer to the beginning */
void
gitno_consume
(
gitno_buffer
*
buf
,
const
char
*
ptr
)
int
gitno_consume
(
gitno_buffer
*
buf
,
const
char
*
ptr
)
{
size_t
consumed
;
assert
(
ptr
-
buf
->
data
>=
0
);
assert
(
ptr
-
buf
->
data
<=
(
int
)
buf
->
len
);
GIT_ASSERT
(
ptr
-
buf
->
data
>=
0
);
GIT_ASSERT
(
ptr
-
buf
->
data
<=
(
int
)
buf
->
len
);
consumed
=
ptr
-
buf
->
data
;
memmove
(
buf
->
data
,
ptr
,
buf
->
offset
-
consumed
);
memset
(
buf
->
data
+
buf
->
offset
,
0x0
,
buf
->
len
-
buf
->
offset
);
buf
->
offset
-=
consumed
;
return
0
;
}
/* Consume const bytes and move the rest of the buffer to the beginning */
...
...
src/netops.h
View file @
05816a98
...
...
@@ -62,7 +62,7 @@ void gitno_buffer_setup_fromstream(git_stream *st, gitno_buffer *buf, char *data
void
gitno_buffer_setup_callback
(
gitno_buffer
*
buf
,
char
*
data
,
size_t
len
,
int
(
*
recv
)(
gitno_buffer
*
buf
),
void
*
cb_data
);
int
gitno_recv
(
gitno_buffer
*
buf
);
void
gitno_consume
(
gitno_buffer
*
buf
,
const
char
*
ptr
);
int
gitno_consume
(
gitno_buffer
*
buf
,
const
char
*
ptr
);
void
gitno_consume_n
(
gitno_buffer
*
buf
,
size_t
cons
);
#endif
src/transports/smart_protocol.c
View file @
05816a98
...
...
@@ -64,7 +64,9 @@ int git_smart__store_refs(transport_smart *t, int flushes)
continue
;
}
gitno_consume
(
buf
,
line_end
);
if
(
gitno_consume
(
buf
,
line_end
)
<
0
)
return
-
1
;
if
(
pkt
->
type
==
GIT_PKT_ERR
)
{
git_error_set
(
GIT_ERROR_NET
,
"remote error: %s"
,
((
git_pkt_err
*
)
pkt
)
->
error
);
git__free
(
pkt
);
...
...
@@ -236,7 +238,9 @@ static int recv_pkt(git_pkt **out_pkt, git_pkt_type *out_type, gitno_buffer *buf
}
}
while
(
error
);
gitno_consume
(
buf
,
line_end
);
if
(
gitno_consume
(
buf
,
line_end
)
<
0
)
return
-
1
;
if
(
out_type
!=
NULL
)
*
out_type
=
pkt
->
type
;
if
(
out_pkt
!=
NULL
)
...
...
@@ -791,7 +795,8 @@ static int parse_report(transport_smart *transport, git_push *push)
continue
;
}
gitno_consume
(
buf
,
line_end
);
if
(
gitno_consume
(
buf
,
line_end
)
<
0
)
return
-
1
;
error
=
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