[PATCH 08/10] refs.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-8-gitter.spiros@gmail.com>
- In-Reply-To
- <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> --- refs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/refs.c b/refs.c index 87dc82f..c797ea0 100644 --- a/refs.c +++ b/refs.c @@ -912,7 +912,7 @@ char *shorten_unambiguous_ref(const char *refname, int strict) for (i = 0; i < nr_rules; i++) { assert(offset < total_len); scanf_fmts[i] = (char *)&scanf_fmts[nr_rules] + offset; - offset += snprintf(scanf_fmts[i], total_len - offset, + offset += xsnprintf(scanf_fmts[i], total_len - offset, ref_rev_parse_rules[i], 2, "%s") + 1; } }
-- 2.9.0.rc1.265.geb5d750