From 87c0260e1e64bdbd876e632c13e3d83cf2dbfd31 Mon Sep 17 00:00:00 2001 From: Nicolas Hillegeer Date: Sat, 31 May 2014 20:12:12 +0200 Subject: [PATCH] coverity/13685: silence NUL-termnation fp It was a false positive, but it can't hurt to "fix" it. Original warning: CID 13685 (#1 of 1): Buffer not null terminated (BUFFER_SIZE) 6. buffer_size: Calling strncpy with a source string whose length (4 chars) is greater than or equal to the size argument (4) will fail to null-terminate b0p->b0_version. --- src/nvim/memline.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 19c3cfe99412a9..63a05e7b59e19a 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -304,8 +304,7 @@ int ml_open(buf_T *buf) b0p->b0_magic_int = (int)B0_MAGIC_INT; b0p->b0_magic_short = (short)B0_MAGIC_SHORT; b0p->b0_magic_char = B0_MAGIC_CHAR; - STRNCPY(b0p->b0_version, "VIM ", 4); - STRNCPY(b0p->b0_version + 4, Version, 6); + xstrlcpy(xstpcpy((char *) b0p->b0_version, "VIM "), Version, 6); long_to_char((long)mfp->mf_page_size, b0p->b0_page_size); if (!buf->b_spell) {