git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Antoine Pelisse <apelisse@gmail.com>
Cc: git <git@vger.kernel.org>
Subject: Re: [PATCH v2 03/10] mailmap: remove email copy and length limitation
Date: Wed, 09 Jan 2013 09:46:30 -0800	[thread overview]
Message-ID: <7vfw2a6yh5.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <CALWbr2wp7rV7Vh0=gwmWaZE5hLHQNL+UciDsL+z-1GyhS9pTkQ@mail.gmail.com> (Antoine Pelisse's message of "Wed, 9 Jan 2013 18:35:21 +0100")

Antoine Pelisse <apelisse@gmail.com> writes:

>> +static struct string_list_item *lookup_prefix(struct string_list *map,
>> +                                             const char *string, size_t len)
>> +{
>> +       int i = string_list_find_insert_index(map, string, 1);
>> +       if (i < 0) {
>> +               /* exact match */
>> +               i = -1 - i;
>> +               /* does it match exactly? */
>> +               if (!map->items[i].string[len])
>> +                       return &map->items[i];
>
> I'm not sure the condition above is necessary, as I don't see why an
> exact match would not be an exact match.

You have a overlong string "ABCDEFG", but you only want to look for
"ABCDEF", i.e. len=6.  The string_list happens to have an existing
string "ABCDEFG".  The insert-index function will report an exact
match, but that does not mean you found what you are looking for. 

For the particular case of "looking up e-mail from a string-list
used for the mailmap, using a string that potentially has an extra
'>' at the end", it may not be an issue (i.e. your overlong string
would be "ABCDEF>", and the string-list used for the mailmap will
not have an entry that ends with '>'), but it is likely that people
will try to mimic this function or try to generalize and move it to
strbuf.c and at that point, such a special case condition will no
longer hold and the bug will manifest itself.  Being defensive like
the above is a way to avoid that.

  reply	other threads:[~2013-01-09 17:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-08  0:10 [PATCH v2 00/10] reroll of ap/log-mailmap Junio C Hamano
2013-01-08  0:10 ` [PATCH v2 01/10] string-list: allow case-insensitive string list Junio C Hamano
2013-01-10 21:35   ` René Scharfe
2013-01-08  0:10 ` [PATCH v2 02/10] Use split_ident_line to parse author and committer Junio C Hamano
2013-01-08  0:10 ` [PATCH v2 03/10] mailmap: remove email copy and length limitation Junio C Hamano
2013-01-09 17:35   ` Antoine Pelisse
2013-01-09 17:46     ` Junio C Hamano [this message]
2013-01-09 17:56       ` Junio C Hamano
2013-01-08  0:10 ` [PATCH v2 04/10] mailmap: simplify map_user() interface Junio C Hamano
2013-01-08  0:10 ` [PATCH v2 05/10] mailmap: add mailmap structure to rev_info and pp Junio C Hamano
2013-01-08  0:10 ` [PATCH v2 06/10] pretty: use mailmap to display username and email Junio C Hamano
2013-01-08  0:10 ` [PATCH v2 07/10] log: add --use-mailmap option Junio C Hamano
2013-01-08  0:10 ` [PATCH v2 08/10] test: add test for " Junio C Hamano
2013-01-08  0:10 ` [PATCH v2 09/10] log: grep author/committer using mailmap Junio C Hamano
2013-01-08  0:10 ` [PATCH v2 10/10] log: add log.mailmap configuration option Junio C Hamano
2013-01-08  7:27 ` [PATCH v2 00/10] reroll of ap/log-mailmap Antoine Pelisse
2013-01-08  7:39   ` Junio C Hamano
2013-01-08  8:02     ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=7vfw2a6yh5.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=apelisse@gmail.com \
    --cc=git@vger.kernel.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).