diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2013-09-09 20:57:56 +0700 |
---|---|---|
committer | Nicolas Pitre <nico@fluxnic.net> | 2013-09-13 21:00:29 -0400 |
commit | de777be821f96f0d4413b071ca454de2747ffcf4 (patch) | |
tree | 1b31aa7a71b79df3b259c0a07add8f604805df62 | |
parent | d552beddb253da2e6fe49680835cf51f31ec40c1 (diff) | |
download | git-de777be821f96f0d4413b071ca454de2747ffcf4.tar.gz |
pack_write: tighten valid object type check in encode_in_pack_object_header
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
-rw-r--r-- | pack-write.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/pack-write.c b/pack-write.c index 88e4788f4b..36b88a3453 100644 --- a/pack-write.c +++ b/pack-write.c @@ -325,8 +325,17 @@ int encode_in_pack_object_header(enum object_type type, uintmax_t size, unsigned int n = 1; unsigned char c; - if (type < OBJ_COMMIT || type > OBJ_REF_DELTA) + switch (type) { + case OBJ_COMMIT: + case OBJ_TREE: + case OBJ_BLOB: + case OBJ_TAG: + case OBJ_OFS_DELTA: + case OBJ_REF_DELTA: + break; + default: die("bad type %d", type); + } c = (type << 4) | (size & 15); size >>= 4; |