fast-import: use xsnprintf for writing sha1s
When we have to write a sha1 with a newline, we do so by copying both into a single buffer, so that we can issue a single write() call. We use snprintf but don't bother to check the output, since we know it will fit. However, we should use xsnprintf() in such a case so that we're notified if our assumption turns out to be wrong (and to make it easier to audit for unchecked snprintf calls). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Mar 24, 2017 at 13:25 UTC
614b19542f649945774a084f2bcf56191f46947c
1 file changed
+1
-1
fast-import.c
+1
-1
@@ -3003,7 +3003,7 @@ static void parse_get_mark(const char *p)
3003
if (!oe)
3004
die("Unknown mark: %s", command_buf.buf);
3005
3006
- snprintf(output, sizeof(output), "%s\n", sha1_to_hex(oe->idx.sha1));
3006
+ xsnprintf(output, sizeof(output), "%s\n", sha1_to_hex(oe->idx.sha1));
3007
cat_blob_write(output, 41);
3008
}
3009