From: Andreas Ericsson <ae@op5.se>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jim Meyering <jim@meyering.net>, 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: Fri, 27 Apr 2012 14:55:10 +0200 [thread overview]
Message-ID: <4F9A972E.7050401@op5.se> (raw)
In-Reply-To: <xmqq62cma2uo.fsf@junio.mtv.corp.google.com>
On 04/26/2012 06:13 PM, Junio C Hamano 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?
>
"terminate" sounds pretty final though. How about strbuf_ensure_suffixch()?
It embeds the 'ch', marking it as a char argument and provides natural names
for
strbuf_ensure_suffix(buf, char *str);
strbuf_ensure_prefix(buf, char *str);
strbuf_ensure_prefixch(buf, char c);
if those are ever needed.
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
next prev parent reply other threads:[~2012-04-27 12:55 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
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 [this message]
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=4F9A972E.7050401@op5.se \
--to=ae@op5.se \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jim@meyering.net \
--cc=mk@acc.umu.se \
/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.