Signed-off-by: Johan Herland <johan@xxxxxxxxxxx> --- mktag.c | 94 --------------------------------------------------------------- 1 files changed, 0 insertions(+), 94 deletions(-) diff --git a/mktag.c b/mktag.c index 5780f33..4f226ab 100644 --- a/mktag.c +++ b/mktag.c @@ -14,100 +14,6 @@ * shortest single-character-tag line. */ -/* - * We refuse to tag something we can't verify. Just because. - */ -static int verify_object(unsigned char *sha1, const char *expected_type) -{ - int ret = -1; - enum object_type type; - unsigned long size; - void *buffer = read_sha1_file(sha1, &type, &size); - - if (buffer) { - if (type == type_from_string(expected_type)) - ret = check_sha1_signature(sha1, buffer, size, expected_type); - free(buffer); - } - return ret; -} - -static int verify_tag(char *data, unsigned long size) -{ -#ifdef NO_C99_FORMAT -#define PD_FMT "%d" -#else -#define PD_FMT "%td" -#endif - - unsigned char sha1[20]; - char type[20]; - const char *type_line, *tag_line, *tagger_line; - unsigned long type_len; - - if (size < 64) - return error("wanna fool me ? you obviously got the size wrong !"); - - /* Verify object line */ - if (memcmp(data, "object ", 7)) - return error("char%d: does not start with \"object \"", 0); - - if (get_sha1_hex(data + 7, sha1)) - return error("char%d: could not get SHA1 hash", 7); - - /* Verify type line */ - type_line = data + 48; - if (memcmp(type_line - 1, "\ntype ", 6)) - return error("char%d: could not find \"\\ntype \"", 47); - - /* Verify tag-line */ - tag_line = strchr(type_line, '\n'); - if (!tag_line++) - return error("char" PD_FMT ": could not find next \"\\n\"", type_line - data); - if (memcmp(tag_line, "tag ", 4) || tag_line[4] == '\n') - return error("char" PD_FMT ": no \"tag \" found", tag_line - data); - - /* Verify the tagger line */ - tagger_line = strchr(tag_line, '\n'); - if (!tagger_line++) - return error("char" PD_FMT ": could not find next \"\\n\"", tag_line - data); - if (memcmp(tagger_line, "tagger ", 7) || (tagger_line[7] == '\n')) - return error("char" PD_FMT ": could not find \"tagger\"", tagger_line - data); - - /* Get the actual type */ - type_len = tag_line - type_line - strlen("type \n"); - if (type_len >= sizeof(type)) - return error("char" PD_FMT ": type too long", type_line + 5 - data); - memcpy(type, type_line + 5, type_len); - type[type_len] = '\0'; - - { - unsigned long i; - - /* Verify that the object matches */ - if (verify_object(sha1, type)) - return error("char%d: could not verify object %s", 7, sha1_to_hex(sha1)); - - /* Verify the tag-name: we don't allow control characters or spaces in it */ - for (i = 4;;) { - unsigned char c = tag_line[i++]; - if (c == '\n') - break; - if (c > ' ') - continue; - return error("char" PD_FMT ": could not verify tag name", tag_line + i - data); - } - } - - /* TODO: check for committer info + blank line? */ - /* Also, the minimum length is probably + "tagger .", or 63+8=71 */ - - /* The actual stuff afterwards we don't care about.. */ - return 0; - -#undef PD_FMT -} - int main(int argc, char **argv) { unsigned long size = 4096; -- 1.5.2 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html