Patch 9.0.0105
Problem:    Illegal memory access when pattern starts with illegal byte.
Solution:   Do not match a character with an illegal byte.
Files:      src/regexp.c, src/testdir/test_regexp_utf8.vim


*** ../vim-9.0.0104/src/regexp.c        2022-07-25 18:13:33.050580738 +0100
--- src/regexp.c        2022-07-29 16:20:18.928360328 +0100
***************
*** 1641,1647 ****
        {
            if (enc_utf8 && c > 0x80)
            {
!               if (utf_fold(utf_ptr2char(p)) == cc)
                    return p;
            }
            else if (*p == c || *p == cc)
--- 1641,1651 ----
        {
            if (enc_utf8 && c > 0x80)
            {
!               int uc = utf_ptr2char(p);
! 
!               // Do not match an illegal byte.  E.g. 0xff matches 0xc3 0xbf,
!               // not 0xff.
!               if ((uc < 0x80 || uc != *p) && utf_fold(uc) == cc)
                    return p;
            }
            else if (*p == c || *p == cc)
*** ../vim-9.0.0104/src/testdir/test_regexp_utf8.vim    2022-02-22 
16:17:59.000000000 +0000
--- src/testdir/test_regexp_utf8.vim    2022-07-29 16:19:29.376442568 +0100
***************
*** 1,5 ****
--- 1,7 ----
  " Tests for regexp in utf8 encoding
  
+ source shared.vim
+ 
  func s:equivalence_test()
    let str = "AÀÁÂÃÄÅĀĂĄǍǞǠǺȂȦȺḀẠẢẤẦẨẪẬẮẰẲẴẶ BƁɃḂḄḆ CÇĆĈĊČƇȻḈꞒ DĎĐƊḊḌḎḐḒ 
EÈÉÊËĒĔĖĘĚȄȆȨɆḔḖḘḚḜẸẺẼẾỀỂỄỆ FƑḞꞘ GĜĞĠĢƓǤǦǴḠꞠ HĤĦȞḢḤḦḨḪⱧ IÌÍÎÏĨĪĬĮİƗǏȈȊḬḮỈỊ JĴɈ 
KĶƘǨḰḲḴⱩꝀ LĹĻĽĿŁȽḶḸḺḼⱠ MḾṀṂ NÑŃŅŇǸṄṆṈṊꞤ OÒÓÔÕÖØŌŎŐƟƠǑǪǬǾȌȎȪȬȮȰṌṎṐṒỌỎỐỒỔỖỘỚỜỞỠỢ 
PƤṔṖⱣ QɊ RŔŖŘȐȒɌṘṚṜṞⱤꞦ SŚŜŞŠȘṠṢṤṦṨⱾꞨ TŢŤŦƬƮȚȾṪṬṮṰ 
UÙÚÛÜŨŪŬŮŰƯǕǙǛǓǗȔȖɄṲṴṶṸṺỤỦỨỪỬỮỰ  VƲṼṾ WŴẀẂẄẆẈ XẊẌ YÝŶŸƳȲɎẎỲỴỶỸ ZŹŻŽƵẐẒẔⱫ 
aàáâãäåāăąǎǟǡǻȃȧᶏḁẚạảấầẩẫậắằẳẵặⱥ bƀɓᵬᶀḃḅḇ cçćĉċčƈȼḉꞓꞔ dďđɗᵭᶁᶑḋḍḏḑḓ 
eèéêëēĕėęěȅȇȩɇᶒḕḗḙḛḝẹẻẽếềểá
 ��ệ fƒᵮᶂḟꞙ gĝğġģǥǧǵɠᶃḡꞡ hĥħȟḣḥḧḩḫẖⱨꞕ iìíîïĩīĭįǐȉȋɨᶖḭḯỉị jĵǰɉ kķƙǩᶄḱḳḵⱪꝁ 
lĺļľŀłƚḷḹḻḽⱡ mᵯḿṁṃ nñńņňʼnǹᵰᶇṅṇṉṋꞥ oòóôõöøōŏőơǒǫǭǿȍȏȫȭȯȱɵṍṏṑṓọỏốồổỗộớờởỡợ 
pƥᵱᵽᶈṕṗ qɋʠ rŕŗřȑȓɍɽᵲᵳᶉṛṝṟꞧ sśŝşšșȿᵴᶊṡṣṥṧṩꞩ tţťŧƫƭțʈᵵṫṭṯṱẗⱦ 
uùúûüũūŭůűųǚǖưǔǘǜȕȗʉᵾᶙṳṵṷṹṻụủứừửữự vʋᶌṽṿ wŵẁẃẅẇẉẘ xẋẍ yýÿŷƴȳɏẏẙỳỵỷỹ zźżžƶᵶᶎẑẓẕⱬ"
    let groups = split(str)
***************
*** 560,565 ****
--- 562,580 ----
    call delete('Xinvalid')
  endfunc
  
+ func Test_match_illegal_byte()
+   let lines =<< trim END
+       silent! buffer ÿ\c
+       next ÿ
+       0scriptnames
+       source
+   END
+   call writefile(lines, 'Xregexp')
+   call system(GetVimCommand() .. ' -X -Z -e -s -S Xregexp -c qa!')
+ 
+   call delete('Xregexp')
+ endfunc
+ 
  func Test_match_too_complicated()
    set regexpengine=1
    exe "noswapfile vsplit \xeb\xdb\x99"
*** ../vim-9.0.0104/src/version.c       2022-07-29 15:28:24.019397903 +0100
--- src/version.c       2022-07-29 16:21:52.268212000 +0100
***************
*** 737,738 ****
--- 737,740 ----
  {   /* Add new patch number below this line */
+ /**/
+     105,
  /**/

-- 
I'm in shape.  Round IS a shape.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220729152304.016E11C0C34%40moolenaar.net.

Raspunde prin e-mail lui