From b1cc7bfe3a6fb95d55fd786f8496c5f973d3ed1d Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 17 Mar 2015 17:17:35 +0800 Subject: [PATCH] Fix CID 39902: Insure that buffer is properly terminated after a strncpy. --- isearch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/isearch.c b/isearch.c index 97f4339..d9532fb 100644 --- a/isearch.c +++ b/isearch.c @@ -198,7 +198,8 @@ static int isearch(int f, int n) cmd_reexecute = -1; /* We're not re-executing (yet?) */ cmd_offset = 0; /* Start at the beginning of the buff */ cmd_buff[0] = '\0'; /* Init the command buffer */ - strncpy( pat_save, pat, sizeof pat_save) ; /* Save the old pattern string */ + strncpy( pat_save, pat, sizeof pat_save - 1) ; /* Save the old pattern string */ + pat_save[ sizeof pat_save - 1] = '\0' ; curline = curwp->w_dotp; /* Save the current line pointer */ curoff = curwp->w_doto; /* Save the current offset */ init_direction = n; /* Save the initial search direction */