From: Junio C Hamano <junkio@cox.net>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org, Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH] Limit filename for format-patch
Date: Sat, 24 Feb 2007 00:51:34 -0800 [thread overview]
Message-ID: <7vtzxcym3t.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <20070223222606.28660.46208.stgit@lathund.dewire.com> (Robin Rosenberg's message of "Fri, 23 Feb 2007 23:27:58 +0100")
Robin Rosenberg <robin.rosenberg@dewire.com> writes:
> -static void reopen_stdout(struct commit *commit, int nr, int keep_subject)
> +static int reopen_stdout(struct commit *commit, int nr, int keep_subject)
> {
> - char filename[1024];
> + char filename[PATH_MAX];
> char *sol;
> int len = 0;
> - int suffix_len = strlen(fmt_patch_suffix) + 10; /* ., NUL and slop */
> + int suffix_len = strlen(fmt_patch_suffix) + 1;
>
> if (output_directory) {
> - strlcpy(filename, output_directory, 1000);
> + if (strlen(output_directory) >= sizeof(filename) - 64 - suffix_len)
> + return error("name of output directory is too long");
> + strlcpy(filename, output_directory, sizeof(filename) - suffix_len);
Sorry for a late doubt, but I started wondering if we should use
NAME_MAX instead of hardcoded 64. Purists might argue for using
pathconf() but I think it is an overkill.
NAME_MAX is 255 on Linux, POSIX says it should be 14 at least
(and further says if the platform supports only smaller max,
NAME_MAX should not be defined -- heh). I do not know how
universal NAME_MAX is defined, and I hate dealing with header
incompatibility across different systems, so I am tempted to
just do something like:
#define FORMAT_PATCH_NAME_MAX 64
locally, and use that instead.
next prev parent reply other threads:[~2007-02-24 8:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-23 0:37 [PATCH] Limit filename for format-patch Robin Rosenberg
2007-02-23 0:49 ` Johannes Schindelin
2007-02-23 21:39 ` Robin Rosenberg
2007-02-23 21:47 ` Robin Rosenberg
2007-02-23 22:27 ` Robin Rosenberg
2007-02-24 1:27 ` Johannes Schindelin
2007-02-24 1:33 ` Junio C Hamano
2007-02-24 8:51 ` Junio C Hamano [this message]
2007-02-24 11:24 ` Robin Rosenberg
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=7vtzxcym3t.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=robin.rosenberg@dewire.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).