Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e169830

Browse files
author
Sim Domingo
committed
fix truncation error in git_odb__error_notfound() when oid_len==GIT_OID_HEXSZ
1 parent f0ee795 commit e169830

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/odb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,8 +1361,10 @@ int git_odb__error_notfound(
13611361
const char *message, const git_oid *oid, size_t oid_len)
13621362
{
13631363
if (oid != NULL) {
1364+
size_t buf_len = oid_len;
1365+
if (oid_len == GIT_OID_HEXSZ) buf_len++;
13641366
char oid_str[GIT_OID_HEXSZ + 1];
1365-
git_oid_tostr(oid_str, oid_len, oid);
1367+
git_oid_tostr(oid_str, buf_len, oid);
13661368
giterr_set(GITERR_ODB, "Object not found - %s (%.*s)",
13671369
message, oid_len, oid_str);
13681370
} else

0 commit comments

Comments
 (0)