From: Elia Pinto <gitter.spiros@gmail.com>
To: git@vger.kernel.org
Cc: Elia Pinto <gitter.spiros@gmail.com>
Subject: [PATCH 07/10] fast-import.c: convert trivial snprintf calls to xsnprintf
Date: Fri, 3 Jun 2016 07:47:21 +0000 [thread overview]
Message-ID: <20160603074724.12173-7-gitter.spiros@gmail.com> (raw)
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>
---
fast-import.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index 59630ce..5beb63d 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1240,10 +1240,7 @@ static void stream_blob(uintmax_t len, unsigned char *sha1out, uintmax_t mark)
sha1file_checkpoint(pack_file, &checkpoint);
offset = checkpoint.offset;
- hdrlen = snprintf((char *)out_buf, out_sz, "blob %" PRIuMAX, len) + 1;
- if (out_sz <= hdrlen)
- die("impossibly large object header");
-
+ hdrlen = xsnprintf((char *)out_buf, out_sz, "blob %" PRIuMAX, len) + 1;
git_SHA1_Init(&c);
git_SHA1_Update(&c, out_buf, hdrlen);
--
2.9.0.rc1.265.geb5d750
next prev parent reply other threads:[~2016-06-03 7:48 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
2016-06-03 7:47 ` Elia Pinto [this message]
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=20160603074724.12173-7-gitter.spiros@gmail.com \
--to=gitter.spiros@gmail.com \
--cc=git@vger.kernel.org \
/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).