Patch 8.1.1653

7 views
Skip to first unread message

Bram Moolenaar

unread,
Jul 8, 2019, 4:04:28 PM7/8/19
to vim...@googlegroups.com

Patch 8.1.1653
Problem: Ubsan warns for possibly passing NULL pointer.
Solution: Skip code when length is zero. (Dominique Pelle, closes #4631)
Files: src/channel.c


*** ../vim-8.1.1652/src/channel.c 2019-06-28 22:06:41.110072146 +0200
--- src/channel.c 2019-07-08 22:01:10.759502396 +0200
***************
*** 3990,3996 ****
writeq_T *last = wq->wq_prev;

/* append to the last entry */
! if (ga_grow(&last->wq_ga, len) == OK)
{
mch_memmove((char *)last->wq_ga.ga_data
+ last->wq_ga.ga_len,
--- 3990,3996 ----
writeq_T *last = wq->wq_prev;

/* append to the last entry */
! if (len > 0 && ga_grow(&last->wq_ga, len) == OK)
{
mch_memmove((char *)last->wq_ga.ga_data
+ last->wq_ga.ga_len,
***************
*** 4012,4018 ****
wq->wq_prev->wq_next = last;
wq->wq_prev = last;
ga_init2(&last->wq_ga, 1, 1000);
! if (ga_grow(&last->wq_ga, len) == OK)
{
mch_memmove(last->wq_ga.ga_data, buf, len);
last->wq_ga.ga_len = len;
--- 4012,4018 ----
wq->wq_prev->wq_next = last;
wq->wq_prev = last;
ga_init2(&last->wq_ga, 1, 1000);
! if (len > 0 && ga_grow(&last->wq_ga, len) == OK)
{
mch_memmove(last->wq_ga.ga_data, buf, len);
last->wq_ga.ga_len = len;
*** ../vim-8.1.1652/src/version.c 2019-07-08 21:57:26.291708275 +0200
--- src/version.c 2019-07-08 22:03:52.403195879 +0200
***************
*** 779,780 ****
--- 779,782 ----
{ /* Add new patch number below this line */
+ /**/
+ 1653,
/**/

--
DENNIS: Listen -- strange women lying in ponds distributing swords is no
basis for a system of government. Supreme executive power derives
from a mandate from the masses, not from some farcical aquatic
ceremony.
The Quest for the Holy Grail (Monty Python)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Dominique Pellé

unread,
Jul 8, 2019, 4:22:55 PM7/8/19
to vim_dev
The 2nd chunk of the diff does not seem correct and
is different from how I fixed it in my original PR.

If len is 0, old code used to set last->wq_ga.ga_len to 0 but now
that this is skipped. Only the mch_memmove(...) called should have
been skipped.

Regards
Dominique

Bram Moolenaar

unread,
Jul 8, 2019, 5:30:48 PM7/8/19
to vim...@googlegroups.com, Dominique Pellé
That should be OK, because ga_init2() sets the length to zero.
But perhaps Ubsan doesn't handle this logic?

--
Courtroom Quote #19:
Q: Doctor, how many autopsies have you performed on dead people?
A: All my autopsies have been performed on dead people.
Reply all
Reply to author
Forward
0 new messages