]> granicus.if.org Git - vim/commitdiff
patch 8.0.0213: Netbeans specialKeys command does not check argument length v8.0.0213
authorBram Moolenaar <Bram@vim.org>
Sun, 22 Jan 2017 14:19:22 +0000 (15:19 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 22 Jan 2017 14:19:22 +0000 (15:19 +0100)
Problem:    The Netbeans "specialKeys" command does not check if the argument
            fits in the buffer. (Coverity)
Solution:   Add a length check.

src/netbeans.c
src/version.c

index cc5560412724018a6881517315f1e59afd785ad3..fb4cb766d0bba5618d66bc3b613cfa25d702e05c 100644 (file)
@@ -2332,7 +2332,8 @@ special_keys(char_u *args)
     char *save_str = nb_unquote(args, NULL);
     char *tok = strtok(save_str, " ");
     char *sep;
-    char keybuf[64];
+#define KEYBUFLEN 64
+    char keybuf[KEYBUFLEN];
     char cmdbuf[256];
 
     while (tok != NULL)
@@ -2359,10 +2360,13 @@ special_keys(char_u *args)
            tok++;
        }
 
-       strcpy(&keybuf[i], tok);
-       vim_snprintf(cmdbuf, sizeof(cmdbuf),
-                               "<silent><%s> :nbkey %s<CR>", keybuf, keybuf);
-       do_map(0, (char_u *)cmdbuf, NORMAL, FALSE);
+       if (strlen(tok) + i < KEYBUFLEN)
+       {
+           strcpy(&keybuf[i], tok);
+           vim_snprintf(cmdbuf, sizeof(cmdbuf),
+                                "<silent><%s> :nbkey %s<CR>", keybuf, keybuf);
+           do_map(0, (char_u *)cmdbuf, NORMAL, FALSE);
+       }
        tok = strtok(NULL, " ");
     }
     vim_free(save_str);
index 741b8da1e94b28bbb4889a54390a0afb88bec25f..592c77ca73b9f702e20732c15c930545b2385256 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    213,
 /**/
     212,
 /**/