diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index cf158bf545..efc30b71a0 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -1669,9 +1669,9 @@ restore_backup: #endif if (!filtering) { add_quoted_fname(IObuff, IOSIZE, buf, fname); - // Append the filename to the message ID. + // Append the filename (without trailing char) to the message ID. char msg_id[IOSIZE + 14] = "nvim.bufwrite "; - strncat(msg_id + 14, IObuff, strlen(IObuff) - 1); + xstrlcat(msg_id, IObuff, 14 + strlen(IObuff)); bool insert_space = false; if (write_info.bw_conv_error) { xstrlcat(IObuff, _(" CONVERSION ERROR"), IOSIZE); diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 022509b933..3a679e6454 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -132,9 +132,9 @@ void filemess(buf_T *buf, char *name, char *s) msg_scrolled_ign = true; // may truncate the message to avoid a hit-return prompt if (*s == NUL) { - // Append the filename to the message ID. + // Append the filename (without trailing char) to the message ID. char msg_id[IOSIZE + 14] = "nvim.bufwrite "; - strncat(msg_id + 14, IObuff, strlen(IObuff) - 1); + xstrlcat(msg_id, IObuff, 14 + strlen(IObuff)); msg_progress(IObuff, msg_id, "running", 0, false, true); } else { msg_outtrans(msg_may_trunc(false, IObuff), 0, false);