PCRE2Project / pcre2

PCRE2 development is now based here.
Other
922 stars 194 forks source link

pcre2test: avoid printing invalid utf trail in partial match #237

Closed carenas closed 1 year ago

carenas commented 1 year ago

This could result in a buffer over read as reported in the linked ticket and that was only possible after 10.34 when match_invalid_utf was introduced, or if invalid data was matched without UTF validation, which is known to have undefined behaviour.

Also makes utf82ord() save when used with invalid UTF, as the same issue could be triggered in other ways (ex: using aftertext) as shown by:

PCRE2 version 10.34 2019-11-21
  re> /(?<=..)X/match_invalid_utf,aftertext
data> \xc3\xb1x{10ffff}X\xb1\xf4\x8f\xbf

Fixes: #235

PhilipHazel commented 1 year ago

The tests are failing with JIT, it seems.

carenas commented 1 year ago

Shouldn't fail when stacked on top of #238, but will update it once that is settled