From 017b95da3931eb565fe486d259044ea6ade54cdd Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 11 Mar 2019 16:36:12 +0100 Subject: [PATCH] fixup! strbuf_vinsertf: provide the correct buffer size to vsnprintf In preparation for a newer patch series. Signed-off-by: Johannes Schindelin --- strbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strbuf.c b/strbuf.c index 87ecf7f975..bfbbdadbf3 100644 --- a/strbuf.c +++ b/strbuf.c @@ -270,7 +270,7 @@ void strbuf_vinsertf(struct strbuf *sb, size_t pos, const char *fmt, va_list ap) memmove(sb->buf + pos + len, sb->buf + pos, sb->len - pos); /* vsnprintf() will append a NUL, overwriting one of our characters */ save = sb->buf[pos + len]; - len2 = vsnprintf(sb->buf + pos, len + 1, fmt, ap); + len2 = vsnprintf(sb->buf + pos, sb->alloc - sb->len, fmt, ap); sb->buf[pos + len] = save; if (len2 != len) BUG("your vsnprintf is broken (returns inconsistent lengths)");