From b9caa1859d9116959a1aafdb8dc3f6578d692459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20David=20Ib=C3=A1=C3=B1ez?= Date: Fri, 30 Sep 2011 19:50:13 +0200 Subject: [PATCH] oid: now git_oid_fromstrn checks whether the given string is too short MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: J. David Ibáñez --- src/oid.c | 3 +++ 1 file changed, 3 insertions(+) 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;