summaryrefslogtreecommitdiff
path: root/src/oid.c
diff options
context:
space:
mode:
authorJ. David Ibáñez <jdavid.ibp@gmail.com>2011-10-02 21:40:57 +0200
committerJ. David Ibáñez <jdavid.ibp@gmail.com>2011-10-02 21:53:04 +0200
commit0e058e789b5a4a153f9fb5d14860fc38551f0c66 (patch)
treecd939c30dce4123ef164c10da807afa7a6c65ec0 /src/oid.c
parentb9caa1859d9116959a1aafdb8dc3f6578d692459 (diff)
downloadlibgit2-0e058e789b5a4a153f9fb5d14860fc38551f0c66.tar.gz
oid: add missing check to git_oid_fromstrn
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 08e9305b5..b47fa2c77 100644
--- a/src/oid.c
+++ b/src/oid.c
@@ -54,6 +54,9 @@ int git_oid_fromstrn(git_oid *out, const char *str, size_t length)
if (length % 2) {
v = (from_hex[(unsigned char)str[p + 0]] << 4);
+ if (v < 0)
+ return git__throw(GIT_ENOTOID, "Failed to generate sha1. Given string is not a valid sha1 hash");
+
out->id[p / 2] = (unsigned char)v;
p += 2;
}