From: Junio C Hamano <junkio@cox.net>
To: Eygene Ryabinkin <rea-git@codelabs.ru>
Cc: git@vger.kernel.org
Subject: Re: Another memory overrun in http-push.c
Date: Fri, 02 Mar 2007 00:16:28 -0800 [thread overview]
Message-ID: <7vwt20giw3.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <20070301160911.GU57456@codelabs.ru> (Eygene Ryabinkin's message of "Thu, 1 Mar 2007 19:09:12 +0300")
Eygene Ryabinkin <rea-git@codelabs.ru> writes:
> Me again ;))
>
> Spotted another memory overrun in the http-push.c. In principle,
> it is the read-only overrun, but it provokes the coredump on my
> system. The problem is that strlcpy(dst, src, size) returns the
> length of the 'src' and demands it to be NULL-terminated (see
> 'man strlcpy' and http://www.gratisoft.us/todd/papers/strlcpy.html).
> It is not the case for the xml_cdata and possibly other places. So
> I've just replaced strlcpy with memcpy + zero termination all over
> the http-push.c. The patch is below.
Please check Documentation/SubmittingPatches.
Use of strlcpy() in general _is_ stupid if you are computing how
much space is needed, allocating that much as your own buffer
and then copying. strlcpy() needs to say how much it would have
copied if it were given large enough buffer, and it needs to be
able to run strlen(src), so it is not valid to give a buffer
that may not be NUL-terminated as you say.
next prev parent reply other threads:[~2007-03-02 8:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-01 16:09 Another memory overrun in http-push.c Eygene Ryabinkin
2007-03-02 8:16 ` Junio C Hamano [this message]
2007-03-02 10:03 ` Eygene Ryabinkin
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=7vwt20giw3.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=rea-git@codelabs.ru \
/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 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 NNTP newsgroup(s).