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
a59545de
Commit
a59545de
authored
Feb 13, 2017
by
Edward Thomson
Committed by
GitHub
Feb 13, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4122 from pks-t/pks/signature-dbl-free
Signature cleanups
parents
c576d4ff
ade0d9c6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
8 deletions
+13
-8
include/git2/commit.h
+6
-3
src/buffer.h
+2
-1
src/commit.c
+5
-4
No files found.
include/git2/commit.h
View file @
a59545de
...
@@ -255,7 +255,8 @@ GIT_EXTERN(int) git_commit_nth_gen_ancestor(
...
@@ -255,7 +255,8 @@ GIT_EXTERN(int) git_commit_nth_gen_ancestor(
/**
/**
* Get an arbitrary header field
* Get an arbitrary header field
*
*
* @param out the buffer to fill
* @param out the buffer to fill; existing content will be
* overwritten
* @param commit the commit to look in
* @param commit the commit to look in
* @param field the header field to return
* @param field the header field to return
* @return 0 on succeess, GIT_ENOTFOUND if the field does not exist,
* @return 0 on succeess, GIT_ENOTFOUND if the field does not exist,
...
@@ -270,8 +271,10 @@ GIT_EXTERN(int) git_commit_header_field(git_buf *out, const git_commit *commit,
...
@@ -270,8 +271,10 @@ GIT_EXTERN(int) git_commit_header_field(git_buf *out, const git_commit *commit,
* `GITERR_INVALID`. If the commit does not have a signature, the
* `GITERR_INVALID`. If the commit does not have a signature, the
* error class will be `GITERR_OBJECT`.
* error class will be `GITERR_OBJECT`.
*
*
* @param signature the signature block
* @param signature the signature block; existing content will be
* @param signed_data signed data; this is the commit contents minus the signature block
* overwritten
* @param signed_data signed data; this is the commit contents minus the signature block;
* existing content will be overwritten
* @param repo the repository in which the commit exists
* @param repo the repository in which the commit exists
* @param commit_id the commit from which to extract the data
* @param commit_id the commit from which to extract the data
* @param field the name of the header field containing the signature
* @param field the name of the header field containing the signature
...
...
src/buffer.h
View file @
a59545de
...
@@ -66,7 +66,8 @@ extern int git_buf_try_grow(
...
@@ -66,7 +66,8 @@ extern int git_buf_try_grow(
* library, when providing git_buf's, may wish to provide a NULL ptr for
* library, when providing git_buf's, may wish to provide a NULL ptr for
* ease of handling. The buffer routines, however, expect a non-NULL ptr
* ease of handling. The buffer routines, however, expect a non-NULL ptr
* always. This helper method simply handles NULL input, converting to a
* always. This helper method simply handles NULL input, converting to a
* git_buf__initbuf.
* git_buf__initbuf. If a buffer with a non-NULL ptr is passed in, this method
* assures that the buffer is '\0'-terminated.
*/
*/
extern
void
git_buf_sanitize
(
git_buf
*
buf
);
extern
void
git_buf_sanitize
(
git_buf
*
buf
);
...
...
src/commit.c
View file @
a59545de
...
@@ -642,7 +642,7 @@ int git_commit_header_field(git_buf *out, const git_commit *commit, const char *
...
@@ -642,7 +642,7 @@ int git_commit_header_field(git_buf *out, const git_commit *commit, const char *
{
{
const
char
*
eol
,
*
buf
=
commit
->
raw_header
;
const
char
*
eol
,
*
buf
=
commit
->
raw_header
;
git_buf_
sanitize
(
out
);
git_buf_
clear
(
out
);
while
((
eol
=
strchr
(
buf
,
'\n'
)))
{
while
((
eol
=
strchr
(
buf
,
'\n'
)))
{
/* We can skip continuations here */
/* We can skip continuations here */
...
@@ -706,8 +706,8 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
...
@@ -706,8 +706,8 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
const
char
*
h
,
*
eol
;
const
char
*
h
,
*
eol
;
int
error
;
int
error
;
git_buf_
sanitize
(
signature
);
git_buf_
clear
(
signature
);
git_buf_
sanitize
(
signed_data
);
git_buf_
clear
(
signed_data
);
if
(
!
field
)
if
(
!
field
)
field
=
"gpgsig"
;
field
=
"gpgsig"
;
...
@@ -766,8 +766,9 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
...
@@ -766,8 +766,9 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
if
(
git_buf_oom
(
signature
))
if
(
git_buf_oom
(
signature
))
goto
oom
;
goto
oom
;
error
=
git_buf_puts
(
signed_data
,
eol
+
1
);
git_odb_object_free
(
obj
);
git_odb_object_free
(
obj
);
return
git_buf_puts
(
signed_data
,
eol
+
1
)
;
return
error
;
}
}
giterr_set
(
GITERR_OBJECT
,
"this commit is not signed"
);
giterr_set
(
GITERR_OBJECT
,
"this commit is not signed"
);
...
...
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