pack-objects: fix thinko in revalidate code
When revalidating an entry from an existing pack entry->size and entry->type are not necessarily the size of the final object when the entry is deltified, but for base objects they must match. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Sep 3, 2006 at 14:44 UTC
7042dbf7a1e9137eb856b3b086a062561c50b8a3
1 file changed
+7
-6
builtin-pack-objects.c
+7
-6
@@ -247,12 +247,13 @@ static int revalidate_one(struct object_entry *entry,
247
void *data, char *type, unsigned long size)
248
{
249
int err;
250
- if (!data)
251
- return -1;
252
- if (size != entry->size)
253
- return -1;
254
- err = check_sha1_signature(entry->sha1, data, size,
255
- type_names[entry->type]);
250
+ if ((!data) ||
251
+ ((entry->type != OBJ_DELTA) &&
252
+ ( (size != entry->size) ||
253
+ strcmp(type_names[entry->type], type))))
254
+ err = -1;
255
+ else
256
+ err = check_sha1_signature(entry->sha1, data, size, type);
257
free(data);
258
return err;
259
}