comparison src/netbeans.c @ 10646:8cff35d5f5dc v8.0.0213

patch 8.0.0213: Netbeans specialKeys command does not check argument length commit https://github.com/vim/vim/commit/ca24e2cfcfd3f064ea1674886e3dcaa8254ad8d7 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 22 15:19:22 2017 +0100 patch 8.0.0213: Netbeans specialKeys command does not check argument length Problem: The Netbeans "specialKeys" command does not check if the argument fits in the buffer. (Coverity) Solution: Add a length check.
author Christian Brabandt <cb@256bit.org>
date Sun, 22 Jan 2017 15:30:04 +0100
parents 7a4fb555c83a
children 67cf0d45b006
comparison
equal deleted inserted replaced
10645:b3aee1f74787 10646:8cff35d5f5dc
2330 special_keys(char_u *args) 2330 special_keys(char_u *args)
2331 { 2331 {
2332 char *save_str = nb_unquote(args, NULL); 2332 char *save_str = nb_unquote(args, NULL);
2333 char *tok = strtok(save_str, " "); 2333 char *tok = strtok(save_str, " ");
2334 char *sep; 2334 char *sep;
2335 char keybuf[64]; 2335 #define KEYBUFLEN 64
2336 char keybuf[KEYBUFLEN];
2336 char cmdbuf[256]; 2337 char cmdbuf[256];
2337 2338
2338 while (tok != NULL) 2339 while (tok != NULL)
2339 { 2340 {
2340 int i = 0; 2341 int i = 0;
2357 tok++; 2358 tok++;
2358 } 2359 }
2359 tok++; 2360 tok++;
2360 } 2361 }
2361 2362
2362 strcpy(&keybuf[i], tok); 2363 if (strlen(tok) + i < KEYBUFLEN)
2363 vim_snprintf(cmdbuf, sizeof(cmdbuf), 2364 {
2364 "<silent><%s> :nbkey %s<CR>", keybuf, keybuf); 2365 strcpy(&keybuf[i], tok);
2365 do_map(0, (char_u *)cmdbuf, NORMAL, FALSE); 2366 vim_snprintf(cmdbuf, sizeof(cmdbuf),
2367 "<silent><%s> :nbkey %s<CR>", keybuf, keybuf);
2368 do_map(0, (char_u *)cmdbuf, NORMAL, FALSE);
2369 }
2366 tok = strtok(NULL, " "); 2370 tok = strtok(NULL, " ");
2367 } 2371 }
2368 vim_free(save_str); 2372 vim_free(save_str);
2369 } 2373 }
2370 2374