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
d45e9480
Commit
d45e9480
authored
Aug 31, 2013
by
Linquize
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oid: git_oid_shorten_add() sets GITERR_INVALID when OID set is full
parent
0001c023
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
+14
-5
include/git2/oid.h
+2
-2
src/oid.c
+12
-3
No files found.
include/git2/oid.h
View file @
d45e9480
...
@@ -241,13 +241,13 @@ GIT_EXTERN(git_oid_shorten *) git_oid_shorten_new(size_t min_length);
...
@@ -241,13 +241,13 @@ GIT_EXTERN(git_oid_shorten *) git_oid_shorten_new(size_t min_length);
* or freed.
* or freed.
*
*
* For performance reasons, there is a hard-limit of how many
* For performance reasons, there is a hard-limit of how many
* OIDs can be added to a single set (around ~
2
2000, assuming
* OIDs can be added to a single set (around ~
3
2000, assuming
* a mostly randomized distribution), which should be enough
* a mostly randomized distribution), which should be enough
* for any kind of program, and keeps the algorithm fast and
* for any kind of program, and keeps the algorithm fast and
* memory-efficient.
* memory-efficient.
*
*
* Attempting to add more than those OIDs will result in a
* Attempting to add more than those OIDs will result in a
* GIT
_ENOMEM
error
* GIT
ERR_INVALID
error
*
*
* @param os a `git_oid_shorten` instance
* @param os a `git_oid_shorten` instance
* @param text_id an OID in text form
* @param text_id an OID in text form
...
...
src/oid.c
View file @
d45e9480
...
@@ -369,8 +369,10 @@ int git_oid_shorten_add(git_oid_shorten *os, const char *text_oid)
...
@@ -369,8 +369,10 @@ int git_oid_shorten_add(git_oid_shorten *os, const char *text_oid)
bool
is_leaf
;
bool
is_leaf
;
node_index
idx
;
node_index
idx
;
if
(
os
->
full
)
if
(
os
->
full
)
{
giterr_set
(
GITERR_INVALID
,
"Unable to shorten OID - OID set full"
);
return
-
1
;
return
-
1
;
}
if
(
text_oid
==
NULL
)
if
(
text_oid
==
NULL
)
return
os
->
min_length
;
return
os
->
min_length
;
...
@@ -396,12 +398,19 @@ int git_oid_shorten_add(git_oid_shorten *os, const char *text_oid)
...
@@ -396,12 +398,19 @@ int git_oid_shorten_add(git_oid_shorten *os, const char *text_oid)
node
->
tail
=
NULL
;
node
->
tail
=
NULL
;
node
=
push_leaf
(
os
,
idx
,
git__fromhex
(
tail
[
0
]),
&
tail
[
1
]);
node
=
push_leaf
(
os
,
idx
,
git__fromhex
(
tail
[
0
]),
&
tail
[
1
]);
GITERR_CHECK_ALLOC
(
node
);
if
(
node
==
NULL
)
{
if
(
os
->
full
)
giterr_set
(
GITERR_INVALID
,
"Unable to shorten OID - OID set full"
);
return
-
1
;
}
}
}
if
(
node
->
children
[
c
]
==
0
)
{
if
(
node
->
children
[
c
]
==
0
)
{
if
(
push_leaf
(
os
,
idx
,
c
,
&
text_oid
[
i
+
1
])
==
NULL
)
if
(
push_leaf
(
os
,
idx
,
c
,
&
text_oid
[
i
+
1
])
==
NULL
)
{
if
(
os
->
full
)
giterr_set
(
GITERR_INVALID
,
"Unable to shorten OID - OID set full"
);
return
-
1
;
return
-
1
;
}
break
;
break
;
}
}
...
...
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