patch 9.1.0912: xxd: integer overflow with sparse files and -autoskip
Problem: xxd: integer overflow with sparse files and -autoskip
Solution: reset zero_seen when at the limit, change the type to char
(sendittothenewts)
When encountering INT_MAX lines of zeros in the input, xxd overflows an
`int` counter, resulting in undefined behaviour. Usually, this results
in a spurious line of zeros being output every 2**32 lines, while the
"*" line is lost, as is the final line of zeros that delineate the file
size if at end of file.
Since xxd doesn't need to know exactly how many lines are being skipped
when it's > 3, the exact value of the line counter `zero_seen` doesn't
matter and it can simply be reduced in value before the overflow occurs.
Changing the type of `zero_seen` to `signed char` is not important, and
done only to make the bug triggerable with more modest file sizes, and
therefore more convenient to test the fix.
fixes: #16170
closes: #16175
Signed-off-by: sendittothenewts <ross.axe@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
zeertzjq [Sat, 7 Dec 2024 15:09:08 +0000 (16:09 +0100)]
patch 9.1.0911: Variable name for 'messagesopt' doesn't match short name
Problem: Variable name for 'messagesopt' doesn't match short name
(after v9.1.0908)
Solution: Change p_meo to p_mopt. Add more details to docs.
(zeertzjq)
closes: #16182
Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Zdenek Dohnal [Wed, 4 Dec 2024 19:19:40 +0000 (20:19 +0100)]
patch 9.1.0904: Vim9: copy-paste error in class_defining_member()
Problem: Vim9: copy-paste error in class_defining_member()
Solution: use variable type VAR_CLASS instead (Zdenek Dohnal)
Found issue by OpenScanHub:
Error: COPY_PASTE_ERROR (CWE-398):
vim91/src/vim9class.c:3308: original: "VAR_OBJECT" looks like the
original copy.
vim91/src/vim9class.c:3316: copy_paste_error: "VAR_OBJECT" looks like a
copy-paste error.
vim91/src/vim9class.c:3316: remediation: Should it say "VAR_CLASS"
instead?
3314| {
3315| cl_tmp = super;
3316|-> vartype = VAR_OBJECT;
3317| }
3318| }
closes: #16163
Signed-off-by: Zdenek Dohnal <zdohnal@redhat.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Zdenek Dohnal [Wed, 4 Dec 2024 19:16:17 +0000 (20:16 +0100)]
patch 9.1.0903: potential overflow in spell_soundfold_wsal()
Problem: potential overflow in spell_soundfold_wsal()
Solution: Protect wres from buffer overflow, by checking the
length (Zdenek Dohnal)
Error: OVERRUN (CWE-119):
vim91/src/spell.c:3819: cond_const: Checking "reslen < 254" implies that
"reslen" is 254 on the false branch.
vim91/src/spell.c:3833: incr: Incrementing "reslen". The value of "reslen"
is now 255.
vim91/src/spell.c:3792: overrun-local: Overrunning array "wres" of 254
4-byte elements at element index 254 (byte offset 1019) using index
"reslen - 1" (which evaluates to 254).
3789| {
3790| // rule with '<' is used
3791|-> if (reslen > 0 && ws != NULL && *ws != NUL
3792| && (wres[reslen - 1] == c
3793| || wres[reslen - 1] == *ws))
Error: OVERRUN (CWE-119):
vim91/src/spell.c:3819: cond_const: Checking "reslen < 254" implies that
"reslen" is 254 on the false branch.
vim91/src/spell.c:3833: overrun-local: Overrunning array "wres" of 254
4-byte elements at element index 254 (byte offset 1019) using index
"reslen++" (which evaluates to 254).
3831| {
3832| if (c != NUL)
3833|-> wres[reslen++] = c;
3834| mch_memmove(word, word + i + 1,
3835| sizeof(int) * (wordlen -
(i + 1) + 1));
related: #16163
Signed-off-by: Zdenek Dohnal <zdohnal@redhat.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
D. Ben Knoble [Sun, 1 Dec 2024 15:06:18 +0000 (16:06 +0100)]
runtime(helptoc): reload cached g:helptoc.shell_prompt when starting toc
Follow up on PR 10446 [1] so that changes at run-time (or after loading
a vimrc) are reflected at next use. Instead of "uncaching" the variable
by computing SHELL_PROMPT on each use, which could negatively impact
performance, reload any user settings before creating the TOC.
Also make sure, changes to the shell prompt variable do correctly
invalidate b:toc, so that the table of content is correctly re-created
after user makes any changes.
Luca Saccarola [Thu, 28 Nov 2024 21:27:28 +0000 (22:27 +0100)]
patch 9.1.0895: default history value is too small
Problem: default history value is too small
Solution: promote the change from defaults.vim back to
the C core, so increase the default 'history' option value
from 50 to 200 (Lucca Saccarola)
closes: #16129
Signed-off-by: Luca Saccarola <github.e41mv@aleeas.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Aliaksei Budavei [Thu, 28 Nov 2024 21:05:37 +0000 (22:05 +0100)]
patch 9.1.0894: No test for what the spotbug compiler parses
Problem: No test for what the spotbug compiler parses
(after commit: 65311c6f472de67b368)
Solution: Test &makeprg for the SpotBugs compiler plugin
(Aliaksei Budavei)
closes: #16096
Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Milly [Thu, 28 Nov 2024 17:16:55 +0000 (18:16 +0100)]
patch 9.1.0892: the max value of 'tabheight' is limited by other tabpages
Problem: the max value of 'tabheight' is limited by other tabpages
Solution: Limit the maximum value of 'cmdheight' to the current tabpage only.
(Milly)
The Help says that cmdheight is local to the tab page, but says nothing
about the maximum value depending on the state of all tab pages. Users
may wonder why they can't increase cmdheight when there are still rows
available on the current tab page. This PR changes the behavior of
cmdheight so that its maximum value depends only on the state of the
current tab page.
Also, since magic numbers were embedded in various places with the
minimum value of cmdheight being 1, we defined a constant to make it
easier to understand.
closes: #16131
Signed-off-by: Milly <milly.ca@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
glepnir [Wed, 27 Nov 2024 20:53:53 +0000 (21:53 +0100)]
patch 9.1.0891: building the completion list array is inefficient
Problem: building the completion list array is inefficient
Solution: refactor and improve ins_compl_build_pum() func
(glepnir)
current time complexity is O(n^2). I guess garray is not used here to save memory and avoid efficiency
is caused by heap memory allocation. A simple way is to add an extra pointer as a single linked list
to store the matching compl_T, and traverse this single linked list to generate compl_match_array.
The time complexity is O(n x m). The worst case is m=n, but we can still get a little improvement.
Because the if condition does not need to be run at one time. This should be a good solution for now.
Later we may be able to complete it in O(lgn) time. But this requires more reconstruction. So this is
the first step.
closes: #16125
Signed-off-by: glepnir <glephunter@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
zeertzjq [Tue, 26 Nov 2024 14:08:02 +0000 (15:08 +0100)]
patch 9.1.0889: Possible unnecessary redraw after adding/deleting lines
Problem: Possible unnecessary redraw after adding/deleting lines.
Solution: Check b_mod_set before using b_mod_xlines to avoid using stale
b_mod_xlines value (zeertzjq).
closes: #16124
Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
John Marriott [Sat, 23 Nov 2024 13:01:57 +0000 (14:01 +0100)]
patch 9.1.0882: too many strlen() calls in insexpand.c
Problem: too many strlen() calls in insexpand.c
Solution: Refactor insexpand.c and reduce number of calls to STRLEN(),
fix a warning get_next_filename_completion(), add new function
ins_compl_leader_len() (John Marriott)
closes: #16095
Signed-off-by: John Marriott <basilisk@internode.on.net> Signed-off-by: Christian Brabandt <cb@256bit.org>
Chris White [Sat, 23 Nov 2024 12:35:43 +0000 (13:35 +0100)]
patch 9.1.0881: GUI: message dialog may not get focus
Problem: GUI: message dialog may not get focus
Solution: add window manager hint to give focus to the dialog
(Chris White)
Tell the window manager that message dialogs should be given focus when
the user switches from another application back to Vim. This can
happen, e.g., when the user has a file open in Vim and then edits it
in another program.
fixes: #172
closes: #16100
Signed-off-by: Chris White <christopher.white@crowdstrike.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Luca Saccarola [Tue, 19 Nov 2024 21:53:12 +0000 (22:53 +0100)]
Add clang-format config file
This is used in preparation to enable automatic code-formatting in the
following commits. For now let's just add a clang-format config file,
formatting of source files will follow.
related: #16019
Signed-off-by: Luca Saccarola <github.e41mv@aleeas.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Wu, Zhenyu [Tue, 19 Nov 2024 19:55:25 +0000 (20:55 +0100)]
patch 9.1.0876: filetype: openCL files are not recognized
Problem: filetype: openCL files are not recognized
Solution: detect '*.cl' files as opencl or lisp filetype,
include a opencl syntax and filetype plugin (Wu, Zhenyu)
closes: #15825
Signed-off-by: Wu, Zhenyu <wuzhenyu@ustc.edu> Signed-off-by: Christian Brabandt <cb@256bit.org>
Luca Saccarola [Tue, 19 Nov 2024 19:43:52 +0000 (20:43 +0100)]
patch 9.1.0875: filetype: hyprlang detection can be improved
Problem: filetype: hyprlang detection can be improved
Solution: detect '/hypr/*.conf' files as hyprlang filetype,
include basic syntax highlighting (Luca Saccarola)
fixes: #15875
closes: #16064
Signed-off-by: Luca Saccarola <github.e41mv@aleeas.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
patch 9.1.0868: the warning about missing clipboard can be improved
Problem: the warning about missing clipboard can be improved
(after v9.1.0852)
Solution: use different warnings depending on whether or not clipboard
support is included in Vim, update related documentation
Improve the Warnings about missing clipboard registers
- Make it translatable
- Use a different warning, when clipboard support was not compiled in
- add a reference to :h W24
- explain in more detail the error message