From 0e058e789b5a4a153f9fb5d14860fc38551f0c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20David=20Ib=C3=A1=C3=B1ez?= Date: Sun, 2 Oct 2011 21:40:57 +0200 Subject: [PATCH] oid: add missing check to git_oid_fromstrn 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 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; }