summaryrefslogtreecommitdiffstats
path: root/src/ex_cmds.c
AgeCommit message (Collapse)Author
2024-03-21patch 9.1.0195: memleak with ex_drop, NULL dereferencev9.1.0195Christian Brabandt
Problem: memleak with ex_drop(), NULL dereference (zeertzjq) Solution: revert back to ex_rewind(), use curbuf instead of buf fixes: #14246 closes: #14251 Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-20patch 9.1.0192: drop: don't rewind when editing the same filev9.1.0192Christian Brabandt
Problem: :drop tries to :rewind the argumentlist, which results in E37 (after v9.1.0046) Solution: instead of calling ex_rewind(), call open_buffer() only when re-using the initial empty buffer fixes: #14219 closes: #14220 Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-12patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()v9.1.0172zeertzjq
Problem: More code can use ml_get_buf_len() instead of STRLEN(). Solution: Change more STRLEN() calls to ml_get_buf_len(). Also do not set ml_line_textlen in ml_replace_len() if "has_props" is set, because "len_arg" also includes the size of text properties in that case. (zeertzjq) closes: #14183 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-03patch 9.1.0147: Cannot keep a buffer focused in a windowv9.1.0147Colin Kennedy
Problem: Cannot keep a buffer focused in a window (Amit Levy) Solution: Add the 'winfixbuf' window-local option (Colin Kennedy) fixes: #6445 closes: #13903 Signed-off-by: Colin Kennedy <colinvfx@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-09patch 9.1.0089: qsort() comparison functions should be transitivev9.1.0089Christian Brabandt
Problem: qsort() comparison functions should be transitive Solution: Do not subtract values, but rather use explicit comparisons Improve qsort() comparison functions There has been a recent report on qsort() causing out-of-bounds read & write in glibc for non transitive comparison functions https://www.qualys.com/2024/01/30/qsort.txt Even so the bug is in glibc's implementation of the qsort() algorithm, it's bad style to just use substraction for the comparison functions, which may cause overflow issues and as hinted at in OpenBSD's manual page for qsort(): "It is almost always an error to use subtraction to compute the return value of the comparison function." So check the qsort() comparison functions and change them to be safe. closes: #13980 Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-01-23patch 9.1.0047: issues with temp curwin/buf while cmdwin is openv9.1.0047Sean Dewar
Problem: Things that temporarily change/restore curwin/buf (e.g: win_execute, some autocmds) may break assumptions that curwin/buf is the cmdwin when "cmdwin_type != 0", causing issues. Solution: Expose the cmdwin's real win/buf and check that instead. Also try to ensure these variables are NULL if "cmdwin_type == 0", allowing them to be used directly in most cases without checking cmdwin_type. (Sean Dewar) Alternatively, we could ban win_execute in the cmdwin and audit all places that temporarily change/restore curwin/buf, but I didn't notice any problems arising from allowing this (standard cmdwin restrictions still apply, so things that may actually break the cmdwin are still forbidden). closes: #12819 Signed-off-by: Sean Dewar <seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-01-23patch 9.1.0046: :drop does not re-use empty bufferv9.1.0046Rocco Mao
Problem: :drop does not re-use empty buffer (Rocco Mao) Solution: Make :drop re-use an empty buffer (Rocco Mao) fixes: #13851 closes: #13881 Signed-off-by: Rocco Mao <dapeng.mao@qq.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-01-04patch 9.1.0006: is*() and to*() function may be unsafev9.1.0006Keith Thompson
Problem: is*() and to*() function may be unsafe Solution: Add SAFE_* macros and start using those instead (Keith Thompson) Use SAFE_() macros for is*() and to*() functions The standard is*() and to*() functions declared in <ctype.h> have undefined behavior for negative arguments other than EOF. If plain char is signed, passing an unchecked value from argv for from user input to one of these functions has undefined behavior. Solution: Add SAFE_*() macros that cast the argument to unsigned char. Most implementations behave sanely for negative arguments, and most character values in practice are non-negative, but it's still best to avoid undefined behavior. The change from #13347 has been omitted, as this has already been separately fixed in commit ac709e2fc0db6d31abb7da96f743c40956b60c3a (v9.0.2054) fixes: #13332 closes: #13347 Signed-off-by: Keith Thompson <Keith.S.Thompson@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-12-19patch 9.0.2180: POSIX function name in exarg causes issuesv9.0.2180Zoltan Arpadffy
Problem: POSIX function name in exarg struct causes issues on OpenVMS Solution: Rename getline member in exarg struct to ea_getline, remove isinf() workaround for VMS There are compilers that do not treat well POSIX functions - like getline - usage in the structs. Older VMS compilers could digest this... but the newer OpenVMS compilers ( like VSI C x86-64 X7.4-843 (GEM 50XB9) ) cannot deal with these structs. This could be limited to getline() that is defined via getdelim() and might not affect all POSIX functions in general - but avoiding POSIX function names usage in the structs is a "safe side" practice without compromising the functionality or the code readability. The previous OpenVMS X86 port used a workaround limiting the compiler capabilities using __CRTL_VER_OVERRIDE=80400000 In order to make the OpenVMS port future proof, this pull request proposes a possible solution. closes: #13704 Signed-off-by: Zoltan Arpadffy <zoltan.arpadffy@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-12-01patch 9.0.2143: [security]: buffer-overflow in ex_substitutev9.0.2143Christian Brabandt
Problem: [security]: buffer-overflow in ex_substitute Solution: clear memory after allocating When allocating the new_start pointer in ex_substitute() the memory pointer points to some garbage that the following for loop in ex_cmds.c:4743 confuses and causes it to accessing the new_start pointer beyond it's size, leading to a buffer-overlow. So fix this by using alloc_clear() instead of alloc(), which will clear the memory by NUL and therefore cause the loop to terminate correctly. Reported by @henices, thanks! closes: #13596 Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-11-22patch 9.0.2121: [security]: use-after-free in ex_substitutev9.0.2121Christian Brabandt
Problem: [security]: use-after-free in ex_substitute Solution: always allocate memory closes: #13552 A recursive :substitute command could cause a heap-use-after free in Vim (CVE-2023-48706). The whole reproducible test is a bit tricky, I can only reproduce this reliably when no previous substitution command has been used yet (which is the reason, the test needs to run as first one in the test_substitute.vim file) and as a combination of the `:~` command together with a :s command that contains the special substitution atom `~\=` which will make use of a sub-replace special atom and calls a vim script function. There was a comment in the existing :s code, that already makes the `sub` variable allocate memory so that a recursive :s call won't be able to cause any issues here, so this was known as a potential problem already. But for the current test-case that one does not work, because the substitution does not start with `\=` but with `~\=` (and since there does not yet exist a previous substitution atom, Vim will simply increment the `sub` pointer (which then was not allocated dynamically) and later one happily use a sub-replace special expression (which could then free the `sub` var). The following commit fixes this, by making the sub var always using allocated memory, which also means we need to free the pointer whenever we leave the function. Since sub is now always an allocated variable, we also do no longer need the sub_copy variable anymore, since this one was used to indicated when sub pointed to allocated memory (and had therefore to be freed on exit) and when not. Github Security Advisory: https://github.com/vim/vim/security/advisories/GHSA-c8qm-x72m-q53q Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-11-16patch 9.0.2108: [security]: overflow with count for :s commandv9.0.2108Christian Brabandt
Problem: [security]: overflow with count for :s command Solution: Abort the :s command if the count is too large If the count after the :s command is larger than what fits into a (signed) long variable, abort with e_value_too_large. Adds a test with INT_MAX as count and verify it correctly fails. It seems the return value on Windows using mingw compiler wraps around, so the initial test using :s/./b/9999999999999999999999999990 doesn't fail there, since the count is wrapping around several times and finally is no longer larger than 2147483647. So let's just use 2147483647 in the test, which hopefully will always cause a failure Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-09-09patch 9.0.1886: Various Typosv9.0.1886Christian Brabandt
Problem: Various Typos Solution: Fix Typos This is a collection of typo related commits. closes: #12753 closes: #13016 Co-authored-by: Adri Verhoef <a3@a3.xs4all.nl> Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: Viktor Szépe <viktor@szepe.net> Co-authored-by: nuid64 <lvkuzvesov@proton.me> Co-authored-by: Meng Xiangzhuo <aumo@foxmail.com> Co-authored-by: Dominique Pellé <dominique.pelle@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-09-05patch 9.0.1873: [security] heap-buffer-overflow in vim_regsub_bothv9.0.1873Christian Brabandt
Problem: heap-buffer-overflow in vim_regsub_both Solution: Disallow exchanging windows when textlock is active Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-09-02patch 9.0.1849: CI error on different signedness in ex_cmds.cv9.0.1849Christian Brabandt
Problem: CI error on different signedness Solution: cast unsigned to int Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-09-02patch 9.0.1848: [security] buffer-overflow in vim_regsub_both()v9.0.1848Christian Brabandt
Problem: buffer-overflow in vim_regsub_both() Solution: Check remaining space Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-09-02patch 9.0.1841: style: trailing whitespace in ex_cmds.cv9.0.1841Christian Brabandt
Problem: style: trailing whitespace in ex_cmds.c Solution: remove it Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-09-02patch 9.0.1840: [security] use-after-free in do_ecmdv9.0.1840Christian Brabandt
Problem: use-after-free in do_ecmd Solution: Verify oldwin pointer after reset_VIsual() Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-05-20patch 9.0.1571: RedrawingDisabled not used consistentlyv9.0.1571Bram Moolenaar
Problem: RedrawingDisabled not used consistently. Solution: Avoid RedrawingDisabled going negative. Set RedrawingDisabled in win_split_ins(). (closes #11961)
2023-05-10patch 9.0.1538: :wqall does not trigger ExitPrev9.0.1538Bram Moolenaar
Problem: :wqall does not trigger ExitPre. (Bart Libert) Solution: Move preparations for :qall to a common function. (closes #12374)
2023-04-22patch 9.0.1479: small source file problems; outdated list of distrib. filesv9.0.1479Bram Moolenaar
Problem: Small source file problems; outdated list of distributed files. Solution: Small updates to source files and list of distributed files.
2023-03-04patch 9.0.1380: CTRL-X on 2**64 subtracts twov9.0.1380Bram Moolenaar
Problem: CTRL-X on 2**64 subtracts two. (James McCoy) Solution: Correct computation for large number. (closes #12103)
2023-02-20patch 9.0.1330: handling new value of an option has a long "else if" chainv9.0.1330Yegappan Lakshmanan
Problem: Handling new value of an option has a long "else if" chain. Solution: Use a function pointer. (Yegappan Lakshmanan, closes #12015)
2023-01-22patch 9.0.1234: the code style has to be checked manuallyv9.0.1234Bram Moolenaar
Problem: The code style has to be checked manually. Solution: Add basic code style checks in a test. Fix or avoid uncovered problems.
2023-01-09patch 9.0.1166: code is indented more than necessaryv9.0.1166Yegappan Lakshmanan
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11792)
2022-12-30patch 9.0.1115: code is indented more than neededv9.0.1115Yegappan Lakshmanan
Problem: Code is indented more than needed. Solution: Use an early return to reduce indenting. (Yegappan Lakshmanan, closes #11758)
2022-12-23patch 9.0.1092: search error message doesn't show used patternv9.0.1092Rob Pilling
Problem: Search error message doesn't show used pattern. Solution: Pass the actually used pattern to where the error message is given. (Rob Pilling, closes #11742)
2022-11-12patch 9.0.0864: crash when using "!!" without a previous shell commandv9.0.0864Bram Moolenaar
Problem: Crash when using "!!" without a previous shell command. Solution: Check "prevcmd" is not NULL. (closes #11487)
2022-11-08patch 9.0.0845: shell command with just space gives strange errorv9.0.0845shane.xb.qian
Problem: Shell command with just space gives strange error. Solution: Skip white space at start of the argument. (Christian Brabandt, Shane-XB-Qian, closes #11515, closes #11495)
2022-10-29patch 9.0.0820: memory leak with empty shell commandv9.0.0820Bram Moolenaar
Problem: Memory leak with empty shell command. Solution: Free the empty string.
2022-10-22patch 9.0.0817v9.0.0817v9.0.0816Bram Moolenaar
2022-10-22patch 9.0.0815v9.0.0815Martin Tournoij
2022-10-17patch 9.0.0785: memory leak with empty shell commandv9.0.0785Bram Moolenaar
Problem: Memory leak with empty shell command. Solution: Free the allocated memory when bailing out.
2022-10-17patch 9.0.0783: ":!" doesn't do anything but does update the previous commandv9.0.0783Bram Moolenaar
Problem: ":!" doesn't do anything but does update the previous command. Solution: Do not have ":!" change the previous command. (Martin Tournoij, closes #11372)
2022-10-14patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'v9.0.0751Bram Moolenaar
Problem: 'scrolloff' does not work well with 'smoothscroll'. Solution: Make positioning the cursor a bit better. Rename functions.
2022-10-04patch 9.0.0657: too many #ifdefsv9.0.0657Martin Tournoij
Problem: Too many #ifdefs. Solution: Graduate the +cmdwin feature. Now the tiny and small builds are equal, drop the small build. (Martin Tournoij, closes #11268)
2022-10-03patch 9.0.0648: when using powershell input redirection does not workv9.0.0648Yegappan Lakshmanan
Problem: When using powershell input redirection does not work. Solution: Use a different shell command for powershell. (Yegappan Lakshmanan, closes #11257)
2022-09-19patch 9.0.0506: line number argument for :badd does not workv9.0.0506Bram Moolenaar
Problem: Line number argument for :badd does not work. Solution: Set the last cursor position in the new buffer. (closes #11161)
2022-09-17patch 9.0.0491: no good reason to build without the float featurev9.0.0491Bram Moolenaar
Problem: No good reason to build without the float feature. Solution: Remove configure check for float and "#ifdef FEAT_FLOAT".
2022-09-14patch 9.0.0467: build failurev9.0.0467Bram Moolenaar
Problem: Build failure. Solution: Add missing change.
2022-09-13patch 9.0.0457: substitute prompt does not highlight an empty matchv9.0.0457Bram Moolenaar
Problem: Substitute prompt does not highlight an empty match. Solution: Highlight at least one character.
2022-08-31patch 9.0.0340: the 'cmdheight' zero support causes too much troublev9.0.0340Bram Moolenaar
Problem: The 'cmdheight' zero support causes too much trouble. Solution: Revert support for 'cmdheight' being zero.
2022-08-30patch 9.0.0332: overwrite check may block BufWriteCmdv9.0.0332zeertzjq
Problem: Overwrite check may block BufWriteCmd. Solution: Do not use overwrite check when 'buftype' is "acwrite". (closes #11011)
2022-08-29patch 9.0.0318: clearing screen causes flickerv9.0.0318Bram Moolenaar
Problem: Clearing screen causes flicker. Solution: Do not clear but redraw in more cases. Add () to "wait_return".
2022-08-29patch 9.0.0315: shell command is displayed in message windowv9.0.0315Bram Moolenaar
Problem: Shell command is displayed in message window. Solution: Do not echo the shell command in the message window.
2022-08-25patch 9.0.0263: too many #ifdefsv9.0.0263Bram Moolenaar
Problem: Too many #ifdefs. Solution: Make some functions always available.
2022-08-14patch 9.0.0206: redraw flags are not named specificallyv9.0.0206Bram Moolenaar
Problem: Redraw flags are not named specifically. Solution: Prefix "UPD_" to the flags, for UPDate_screen().
2022-08-05patch 9.0.0145: substitute that joins lines drops text propertiesv9.0.0145Bram Moolenaar
Problem: Substitute that joins lines drops text properties. Solution: Move text properties of the last line to the new line.
2022-07-30patch 9.0.0114: the command line takes up space even when not usedv9.0.0114Shougo Matsushita
Problem: The command line takes up space even when not used. Solution: Allow for 'cmdheight' to be set to zero. (Shougo Matsushita, closes #10675, closes #940)
2022-07-26patch 9.0.0085: ":write" fails after ":file name" and the ":edit"v9.0.0085ii14
Problem: ":write" fails after ":file name" and the ":edit". Solution: Reset BF_NOTEDITED when using ":edit". (closes #10790)