public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Jim Meyering <jim@meyering•net>
To: Bert Wesarg <bert.wesarg@googlemail•com>
Cc: Junio C Hamano <gitster@pobox•com>,
	Marcus Karlsson <mk@acc•umu.se>, git list <git@vger•kernel.org>
Subject: Re: [PATCH] diff: avoid stack-buffer-read-overrun for very long name
Date: Thu, 26 Apr 2012 18:26:45 +0200	[thread overview]
Message-ID: <87y5piwjay.fsf@rho.meyering.net> (raw)
In-Reply-To: <CAKPyHN1mFGiZd7dDH-stUmr3H1JHwxcP1DkjCYNXZd6Bt-P7+w@mail.gmail.com> (Bert Wesarg's message of "Thu, 26 Apr 2012 18:21:33 +0200")

Bert Wesarg wrote:
> On Thu, Apr 26, 2012 at 18:13, Junio C Hamano <gitster@pobox•com> wrote:
>> Jim Meyering <jim@meyering•net> writes:
>>
>>> What do you think about replacing those two append-if-needed two-liners:
>>>
>>>     if (buffer2.len && buffer2.buf[buffer2.len - 1] != '/')
>>>             strbuf_addch(&buffer2, '/');
>>>
>>> by something that readably encapsulates the idiom:
>>>
>>>     strbuf_append_if_absent (&buffer2, '/');
>>>
>>> (though the name isn't particularly apt, because you might
>>> take "absent" to mean "not anywhere in the string," so maybe
>>>   strbuf_append_if_not_already_at_end (ugly) or
>>>   strbuf_append_uniq
>>> )
>>
>> I am not good at names, but strbuf_terminate_with(&buffer2, '/')
>> perhaps?
>
> strbuf_ensure_terminator(struct strbuf* buf, int term, int always)?

Nice!  So far, that's the name I prefer.
But why the third parameter?

  reply	other threads:[~2012-04-26 16:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-16 15:20 [PATCH] diff: avoid stack-buffer-read-overrun for very long name Jim Meyering
2012-04-16 22:27 ` Marcus Karlsson
2012-04-24 16:09   ` Jim Meyering
2012-04-25 19:37     ` Junio C Hamano
2012-04-26 15:52       ` Jim Meyering
2012-04-26 16:13         ` Junio C Hamano
2012-04-26 16:21           ` Bert Wesarg
2012-04-26 16:26             ` Jim Meyering [this message]
2012-04-26 16:53               ` Bert Wesarg
2012-04-26 17:26                 ` Jim Meyering
2012-04-26 16:22           ` Jim Meyering
2012-04-27 12:55           ` Andreas Ericsson
2012-04-27 15:07             ` 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

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

  git send-email \
    --in-reply-to=87y5piwjay.fsf@rho.meyering.net \
    --to=jim@meyering$(echo .)net \
    --cc=bert.wesarg@googlemail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=mk@acc$(echo .)umu.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox