All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
To: Antoine Delaite <antoine.delaite@ensimag.grenoble-inp.fr>
Cc: git@vger.kernel.org, remi.lespinet@ensimag.grenoble-inp.fr,
	louis--alexandre.stuber@ensimag.grenoble-inp.fr,
	remi.galan-alfonso@ensimag.grenoble-inp.fr,
	guillaume.pages@ensimag.grenoble-inp.fr, chriscool@tuxfamily.org,
	thomasxnguy@gmail.com, valentinduperray@gmail.com
Subject: Re: [PATCH v2 2/7] bisect: replace hardcoded "bad|good" by variables
Date: Thu, 11 Jun 2015 17:27:21 +0200	[thread overview]
Message-ID: <vpq1thi465i.fsf@anie.imag.fr> (raw)
In-Reply-To: <1433953472-32572-2-git-send-email-antoine.delaite@ensimag.grenoble-inp.fr> (Antoine Delaite's message of "Wed, 10 Jun 2015 18:24:27 +0200")

Antoine Delaite <antoine.delaite@ensimag.grenoble-inp.fr> writes:

> -	if (!strcmp(refname, "bad")) {
> +	char good_prefix[256];
> +	strcpy(good_prefix, name_good);
> +	strcat(good_prefix, "-");

You are silently adding a restriction here: name_good must be small
enough to fit in a 256-bytes array. It's not a terrible restriction, but
what may happen if you break it is a real issue.

Either you have to enforce this restriction somewhere, or you should not
have the restriction at all. I'd vote for the second. strbuf is your
friend here.

> @@ -259,21 +264,21 @@ bisect_state() {
>  
>  bisect_next_check() {
>  	missing_good= missing_bad=
> -	git show-ref -q --verify refs/bisect/bad || missing_bad=t
> -	test -n "$(git for-each-ref "refs/bisect/good-*")" || missing_good=t
> +	git show-ref -q --verify refs/bisect/$NAME_BAD || missing_bad=t
> +	test -n "$(git for-each-ref "refs/bisect/$NAME_GOOD-*")" || missing_good=t

There are other restrictions here: $NAME_BAD must be an acceptable ref
name, and you're not quoting $NAME_BAD hence it must not contain shell
meta-characters (The requirements for ref names almost imply that, but
'foo/bar{a,b}' is accepted and will trigger some expansion if your
/bin/sh is bash for example).

Being an acceptable ref name is a constraint you have to check (Junio
already mentionned check-ref-format). I think quoting variables makes
sense too.

> @@ -421,7 +426,7 @@ bisect_replay () {
>  		start)
>  			cmd="bisect_start $rev"
>  			eval "$cmd" ;;
> -		good|bad|skip)
> +		$NAME_GOOD|$NAME_BAD|skip)

$NAME_GOOD and $NAME_BAD need quoting if you're not sure they don't
contain shell metacharacters.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

  reply	other threads:[~2015-06-11 15:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-10 16:24 [PATCH v2 1/7] bisect : correction of typo Antoine Delaite
2015-06-10 16:24 ` [PATCH v2 2/7] bisect: replace hardcoded "bad|good" by variables Antoine Delaite
2015-06-11 15:27   ` Matthieu Moy [this message]
2015-06-22 12:42     ` Antoine Delaite
2015-06-22 13:47       ` Matthieu Moy
2015-06-10 16:24 ` [PATCH v2 3/7] bisect: simplify the addition of new bisect terms Antoine Delaite
2015-06-10 16:24 ` [PATCH v2 4/7] bisect: add the terms old/new Antoine Delaite
2015-06-10 21:03   ` Junio C Hamano
2015-06-14 11:51     ` Louis-Alexandre Stuber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vpq1thi465i.fsf@anie.imag.fr \
    --to=matthieu.moy@grenoble-inp.fr \
    --cc=antoine.delaite@ensimag.grenoble-inp.fr \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=guillaume.pages@ensimag.grenoble-inp.fr \
    --cc=louis--alexandre.stuber@ensimag.grenoble-inp.fr \
    --cc=remi.galan-alfonso@ensimag.grenoble-inp.fr \
    --cc=remi.lespinet@ensimag.grenoble-inp.fr \
    --cc=thomasxnguy@gmail.com \
    --cc=valentinduperray@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.