threads / patch / 5670

patch, 2 partsRe: [PATCH 1/2] use SHA_DIGEST_LENGTH

Subject: Re: [PATCH 1/2] use SHA_DIGEST_LENGTH

## tl;dr

One message between Sep 24, 2006 and Sep 24, 2006. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

David Rientjes· Sep 24, 2006, 03:33 UTC · lore
On Sat, 23 Sep 2006, David Rientjes wrote:
Show 21 quoted lines
> @@ -202,16 +202,17 @@ int cmd_name_rev(int argc, const char **
>  #define ishex(x) (isdigit((x)) || ((x) >= 'a' && (x) <= 'f'))
>  				if (!ishex(*p))
>  					forty = 0;
> -				else if (++forty == 40 &&
> +				else if (++forty == 2 * SHA_DIGEST_LENGTH &&
>  						!ishex(*(p+1))) {
> -					unsigned char sha1[40];
> +					unsigned char sha1[2 * SHA_DIGEST_LENGTH];
>  					const char *name = "undefined";
>  					char c = *(p+1);
>  
>  					forty = 0;
>  
>  					*(p+1) = 0;
> -					if (!get_sha1(p - 39, sha1)) {
> +					if (!get_sha1(p - (SHA_DIGEST_LENGTH + 1),
> +						      sha1)) {
>  						struct object *o =
>  							lookup_object(sha1);
>  						if (o)
Off by 18 error.
Signed-off-by: David Rientjes <rientjes@cs.washington.edu>
---
 builtin-name-rev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to builtin-name-rev.c +1 −1
diff --git a/builtin-name-rev.c b/builtin-name-rev.c
index f522664..ed99679 100644
--- a/builtin-name-rev.c
+++ b/builtin-name-rev.c
@@ -211,7 +211,7 @@ #define ishex(x) (isdigit((x)) || ((x) >
 					forty = 0;
 
 					*(p+1) = 0;
-					if (!get_sha1(p - (SHA_DIGEST_LENGTH + 1),
+					if (!get_sha1(p - 2 * SHA_DIGEST_LENGTH + 1,
 						      sha1)) {
 						struct object *o =
 							lookup_object(sha1);

← back to recent threads