Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pcre2posix: additional updates for recent changes #338

Merged
merged 3 commits into from
Nov 16, 2023

Conversation

carenas
Copy link
Contributor

@carenas carenas commented Nov 15, 2023

This was originally meant as a "fixup" for the changes introduced in #333, but includes additional changes that are shown independently in case they need to be dropped, albet it includes a critical brown bag patch that fixes a crash on the original code.

  • The first patch is mostly code that I somehow didn't include in my last push as intended.
  • The second patch fixes a crash when pcre2_regerror(.., .., NULL, 0) or equivalent is used.
  • The third patch is documentation updates that might be relevant in addition.

There is actually a fourth patch that actually tightens the issues raised about overlong buffers, but it is not included in this series but kept on its own branch, let me know if you would rather had everything squashed there and in a different PR instead, I will squash them as you prefer, but will suggest getting the first two ASAP otherwise.

@carenas carenas marked this pull request as draft November 15, 2023 20:58
@carenas carenas changed the title pcre2posix: make code warning free and update ChangeLog pcre2posix: additional updates for recent changes Nov 16, 2023
@carenas carenas marked this pull request as ready for review November 16, 2023 02:13
Somehow previous fix was not ammended to include this code change,
take the opportunity to update ChangeLog and do other cleanup so
it will be at least worth a PR.

Those found responsible have been sacked
Since 0710ce2 (pcre2posix: avoid snprintf quirks in regerror (PCRE2Project#333),
2023-11-15), a call for snprintf was replaced by a pair of strncpy
and buf[errbuf_size - 1] = 0, but it didn't account for the case
where errbuf_size == 0.

Make the code conditional to mimic the original logic and avoid
crashing.
POSIX 1003.1-2008 requires that regoff_t be at least as large as
ssize_t or ptrdiff_t, but we use int and therefore any match is
restricted to what that can hold, even in 64-bit architectures.
@PhilipHazel PhilipHazel merged commit c06a4b8 into PCRE2Project:master Nov 16, 2023
8 checks passed
@carenas carenas deleted the regerror branch November 16, 2023 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants