Re: [PATCH] diff: avoid stack-buffer-read-overrun for very long name

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

 



Bert Wesarg wrote:
> On Thu, Apr 26, 2012 at 18:26, Jim Meyering <jim@xxxxxxxxxxxx> wrote:
>> Bert Wesarg wrote:
>>> On Thu, Apr 26, 2012 at 18:13, Junio C Hamano <gitster@xxxxxxxxx> wrote:
>>>> Jim Meyering <jim@xxxxxxxxxxxx> writes:
>>> strbuf_ensure_terminator(struct strbuf* buf, int term, int always)?
>>
>> Nice!  So far, that's the name I prefer.
>> But why the third parameter?
>
> See the second part of my reply:

Oh.  I missed that.

>>>> ------------------------------------
>>>> builtin/branch.c-     if (!buf.len || buf.buf[buf.len-1] != '\n')
>>>> builtin/branch.c:             strbuf_addch(&buf, '\n');
>>>> --
>>>> strbuf.h-     if (sb->len && sb->buf[sb->len - 1] != '\n')
>>>> strbuf.h:             strbuf_addch(sb, '\n');
>>
>> Please note, that while they are checking the .len, they both behave
>> differently if .len == 0 or not.
>> The first always append a '\n', the latter only, if the string isn't empty.

Glad you noticed the difference.
However, is one exception worth complicating the interface?
--
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]