oid: now git_oid_fromstrn checks whether the given string is too short

Signed-off-by: J. David Ibáñez <jdavid.ibp@gmail.com>
This commit is contained in:
J. David Ibáñez 2011-09-30 19:50:13 +02:00
parent 6d8d3f195c
commit b9caa1859d

View File

@ -36,6 +36,9 @@ int git_oid_fromstrn(git_oid *out, const char *str, size_t length)
size_t p; size_t p;
int v; int v;
if (length < 4)
return git__throw(GIT_ENOTOID, "Failed to generate sha1. Given string is too short");
if (length > GIT_OID_HEXSZ) if (length > GIT_OID_HEXSZ)
length = GIT_OID_HEXSZ; length = GIT_OID_HEXSZ;