Commit 0e058e78 by J. David Ibáñez

oid: add missing check to git_oid_fromstrn

Signed-off-by: J. David Ibáñez <jdavid.ibp@gmail.com>
parent b9caa185
...@@ -54,6 +54,9 @@ int git_oid_fromstrn(git_oid *out, const char *str, size_t length) ...@@ -54,6 +54,9 @@ int git_oid_fromstrn(git_oid *out, const char *str, size_t length)
if (length % 2) { if (length % 2) {
v = (from_hex[(unsigned char)str[p + 0]] << 4); 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; out->id[p / 2] = (unsigned char)v;
p += 2; p += 2;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment