From: Jeff King <peff@peff.net>
To: Elia Pinto <gitter.spiros@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 06/10] diff.c: convert trivial snprintf calls to xsnprintf
Date: Fri, 3 Jun 2016 05:03:20 -0400 [thread overview]
Message-ID: <20160603090320.GE28401@sigill.intra.peff.net> (raw)
In-Reply-To: <20160603074724.12173-6-gitter.spiros@gmail.com>
On Fri, Jun 03, 2016 at 07:47:20AM +0000, Elia Pinto wrote:
> diff.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/diff.c b/diff.c
> index d3734d3..fb61539 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -4491,7 +4491,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
> len1 = remove_space(p->one->path, strlen(p->one->path));
> len2 = remove_space(p->two->path, strlen(p->two->path));
> if (p->one->mode == 0)
> - len1 = snprintf(buffer, sizeof(buffer),
> + len1 = xsnprintf(buffer, sizeof(buffer),
> "diff--gita/%.*sb/%.*s"
> "newfilemode%06o"
> "---/dev/null"
More that assume that PATH_MAX is plenty big for any patch we would
see. I'd argue these should be on the heap, which removes that
restriction, and gets rid of the "PATH_MAX * 4 + 20" magic at the top of
the function.
It looks like the buffer just gets fed into sha1, so I was also tempted
to suggest we simply feed the bits of string in directly. But we are
using the format string here to handle the mode, so you'd still have to
deal with that.
-Peff
next prev parent reply other threads:[~2016-06-03 9:03 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-03 7:47 [PATCH 01/10] builtin/commit.c: convert trivial snprintf calls to xsnprintf Elia Pinto
2016-06-03 7:47 ` [PATCH 02/10] builtin/index-pack.c: " Elia Pinto
2016-06-03 8:53 ` Jeff King
2016-06-03 15:32 ` Ramsay Jones
2016-06-03 17:10 ` Jeff King
2016-06-03 7:47 ` [PATCH 03/10] builtin/tag.c: " Elia Pinto
2016-06-03 8:52 ` Jeff King
2016-06-03 15:37 ` Ramsay Jones
2016-06-03 7:47 ` [PATCH 04/10] combine-diff.c: " Elia Pinto
2016-06-03 8:54 ` Jeff King
2016-06-03 7:47 ` [PATCH 05/10] compat/inet_ntop.c: " Elia Pinto
2016-06-03 7:47 ` [PATCH 06/10] diff.c: " Elia Pinto
2016-06-03 9:03 ` Jeff King [this message]
2016-06-03 7:47 ` [PATCH 07/10] fast-import.c: " Elia Pinto
2016-06-03 7:47 ` [PATCH 08/10] refs.c: " Elia Pinto
2016-06-03 7:47 ` [PATCH 09/10] transport-helper.c: " Elia Pinto
2016-06-03 7:47 ` [PATCH 10/10] wrapper.c: " Elia Pinto
2016-06-03 9:13 ` Jeff King
2016-06-03 8:49 ` [PATCH 01/10] builtin/commit.c: " Jeff King
2016-06-03 9:04 ` Jeff King
2016-06-03 15:25 ` Ramsay Jones
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=20160603090320.GE28401@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitter.spiros@gmail.com \
/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).