git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jim Meyering <jim@meyering.net>
Date
Apr 26, 2012, 17:26 UTC
Message-ID
<87ehrawgja.fsf@rho.meyering.net>
In-Reply-To
<CAKPyHN2VkBo6OKgbhTNSu-LFwabGkFFKAF595rJuXbhWwdte+g@mail.gmail.com>
Bert Wesarg wrote:
Show 10 quoted lines
> On Thu, Apr 26, 2012 at 18:26, Jim Meyering <jim@meyering.net> wrote:
>> Bert Wesarg wrote:
>>> On Thu, Apr 26, 2012 at 18:13, Junio C Hamano <gitster@pobox.com> wrote:
>>>> Jim Meyering <jim@meyering.net> 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.
Show 10 quoted lines
>>>> ------------------------------------
>>>> 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?

Previous: Bert WesargNext: Jim Meyering
Message 10 of 13 in “diff: avoid stack-buffer-read-overrun for very long name”
  1. diff: avoid stack-buffer-read-overrun for very long nameJim Meyering, Apr 16, 2012
  2. Marcus KarlssonApr 16, 2012
  3. Jim MeyeringApr 24, 2012
  4. Junio C HamanoApr 25, 2012
  5. Jim MeyeringApr 26, 2012
  6. Junio C HamanoApr 26, 2012
  7. Bert WesargApr 26, 2012
  8. Jim MeyeringApr 26, 2012
  9. Bert WesargApr 26, 2012
  10. Jim MeyeringApr 26, 2012
  11. Jim MeyeringApr 26, 2012
  12. Andreas EricssonApr 27, 2012
  13. Junio C HamanoApr 27, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.