From 8723f216263ba4a0f06be7b93fada863c0931e09 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Mon, 9 Apr 2007 01:06:29 -0400 Subject: make overflow test on delta base offset work regardless of variable size This patch introduces the MSB() macro to obtain the desired number of most significant bits from a given variable independently of the variable type. It is then used to better implement the overflow test on the OBJ_OFS_DELTA base offset variable with the property of always working correctly regardless of the type/size of that variable. Signed-off-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- builtin-unpack-objects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin-unpack-objects.c') diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c index 3956c56334..63f7db6831 100644 --- a/builtin-unpack-objects.c +++ b/builtin-unpack-objects.c @@ -209,7 +209,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size, base_offset = c & 127; while (c & 128) { base_offset += 1; - if (!base_offset || base_offset & ~(~0UL >> 7)) + if (!base_offset || MSB(base_offset, 7)) die("offset value overflow for delta base object"); pack = fill(1); c = *pack; -- cgit v1.2.3