Fix CID 39902: Insure that buffer is properly terminated after a strncpy.

This commit is contained in:
Renaud 2015-03-17 17:17:35 +08:00
parent 911b4cd402
commit b1cc7bfe3a
1 changed files with 2 additions and 1 deletions

View File

@ -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 */