[PATCH 01/10] builtin/commit.c: convert trivial snprintf calls to xsnprintf
- From
Elia Pinto <gitter.spiros@gmail.com>
- Date
- Jun 3, 2016, 07:47 UTC
- Message-ID
- <20160603074724.12173-1-gitter.spiros@gmail.com>
With the commits f2f02675 and 5096d490 we have been converted in some files the call from snprintf/sprintf/strcpy to xsnprintf. This patch converts the remaining calls to snprintf with xsnprintf under the following conditions:
- The call to snprintf does not control the outcome of the command or the presence of truncation errors. - A call to snprintf can generate a fatal error, directly or indirectly.
The other few remaining cases in which a call to snprintf can generate a soft error have not been changed.
Signed-off-by: Elia Pinto <gitter.spiros@gmail.com> --- builtin/commit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/commit.c b/builtin/commit.c index 443ff91..c65abaa 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1552,7 +1552,7 @@ static int run_rewrite_hook(const unsigned char *oldsha1, code = start_command(&proc); if (code) return code; - n = snprintf(buf, sizeof(buf), "%s %s\n", + n = xsnprintf(buf, sizeof(buf), "%s %s\n", sha1_to_hex(oldsha1), sha1_to_hex(newsha1)); sigchain_push(SIGPIPE, SIG_IGN); write_in_full(proc.in, buf, n);
-- 2.9.0.rc1.265.geb5d750