From: Jeff King Date: Sat, 19 May 2018 01:57:58 GMT Subject: [PATCH 3/5] query_fsmonitor: use xsnprintf for formatting integers Message-ID: <20180519015758.GC32492@sigill.intra.peff.net> In-Reply-To: <20180519015444.GA12080@sigill.intra.peff.net> These formatted integers should always fit into their 64-byte buffers. Let's use xsnprintf() to add an assertion that this is the case, which makes auditing for other unchecked snprintfs() easier. Signed-off-by: Jeff King --- fsmonitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fsmonitor.c b/fsmonitor.c index ed3d1a074d..cc19b27e1d 100644 --- a/fsmonitor.c +++ b/fsmonitor.c @@ -104,8 +104,8 @@ static int query_fsmonitor(int version, uint64_t last_update, struct strbuf *que if (!(argv[0] = core_fsmonitor)) return -1; - snprintf(ver, sizeof(ver), "%d", version); - snprintf(date, sizeof(date), "%" PRIuMAX, (uintmax_t)last_update); + xsnprintf(ver, sizeof(ver), "%d", version); + xsnprintf(date, sizeof(date), "%" PRIuMAX, (uintmax_t)last_update); argv[1] = ver; argv[2] = date; argv[3] = NULL; -- 2.17.0.1052.g7d69f75dbf