Re: [RFC/PATCH] tag: disallow '-' as tag name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michael Schubert <mschub@xxxxxxxxxxxxx> writes:

> Add strbuf_check_tag_ref() as helper to check a refname for a tag.
>
> Signed-off-by: Michael Schubert <mschub@xxxxxxxxxxxxx>
> ---

That was quick ;-).

>  builtin/tag.c |   30 ++++++++++++++++++++++--------
>  1 files changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/builtin/tag.c b/builtin/tag.c
> index b66b34a..f087a7f 100644
> --- a/builtin/tag.c
> +++ b/builtin/tag.c
> @@ -352,11 +352,26 @@ static int parse_msg_arg(const struct option *opt, const char *arg, int unset)
>  	return 0;
>  }
>  
> +static int strbuf_check_tag_ref(struct strbuf *sb, const char *name)
> +{
> +	if (name[0] == '-')
> +		return CHECK_REF_FORMAT_ERROR;

So contrary to what the title claims, it forbids a tag that begins with '-',
e.g. '-foo', not just a single dash.  That is fine by me (we do the same
in strbuf-check-branch-ref) but it needs to be explained better.

> +	strbuf_reset(sb);
> +	strbuf_add(sb, "refs/tags/", 10);
> +	strbuf_add(sb, name, strlen(name));

strbuf_addf(sb, "refs/tags/%s", name)?

> +	if (sb->len > PATH_MAX)
> +		die(_("tag name too long: %.*s..."), 50, name);

I think that should be

	if (PATH_MAX <= sb->len)

but I do not see the point of checking against PATH_MAX if you are already
using a strbuf...
--
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


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]