summaryrefslogtreecommitdiff
path: root/src/oid.c
diff options
context:
space:
mode:
authorJ. David Ibáñez <jdavid.ibp@gmail.com>2011-09-30 19:50:13 +0200
committerJ. David Ibáñez <jdavid.ibp@gmail.com>2011-09-30 19:50:13 +0200
commitb9caa1859d9116959a1aafdb8dc3f6578d692459 (patch)
tree7580bfb2a89bc3dd72913c3ddb7845c94ab1f8e9 /src/oid.c
parent6d8d3f195c9377a1fdb3cbde32ec4a677d93b588 (diff)
downloadlibgit2-b9caa1859d9116959a1aafdb8dc3f6578d692459.tar.gz
oid: now git_oid_fromstrn checks whether the given string is too short
Signed-off-by: J. David Ibáñez <jdavid.ibp@gmail.com>
Diffstat (limited to 'src/oid.c')
-rw-r--r--src/oid.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/oid.c b/src/oid.c
index 1f7227410..08e9305b5 100644
--- a/src/oid.c
+++ b/src/oid.c
@@ -36,6 +36,9 @@ int git_oid_fromstrn(git_oid *out, const char *str, size_t length)
size_t p;
int v;
+ if (length < 4)
+ return git__throw(GIT_ENOTOID, "Failed to generate sha1. Given string is too short");
+
if (length > GIT_OID_HEXSZ)
length = GIT_OID_HEXSZ;