Skip to content

[3.11] gh-98740: Fix validation of conditional expressions in RE (GH-98764)#99045

Merged
miss-islington merged 1 commit intopython:3.11from
miss-islington:backport-e9ac890-3.11
Nov 3, 2022
Merged

[3.11] gh-98740: Fix validation of conditional expressions in RE (GH-98764)#99045
miss-islington merged 1 commit intopython:3.11from
miss-islington:backport-e9ac890-3.11

Conversation

@miss-islington
Copy link
Copy Markdown
Contributor

@miss-islington miss-islington commented Nov 3, 2022

In very rare circumstances the JUMP opcode could be confused with the
argument of the opcode in the "then" part which doesn't end with the
JUMP opcode. This led to incorrect detection of the final JUMP opcode
and incorrect calculation of the size of the subexpression.

NOTE: Changed return value of functions _validate_inner() and
_validate_charset() in Modules/_sre/sre.c. Now they return 0 on success,
-1 on failure, and 1 if the last op is JUMP (which usually is a failure).
Previously they returned 1 on success and 0 on failure.
(cherry picked from commit e9ac890)

Co-authored-by: Serhiy Storchaka storchaka@gmail.com

…onGH-98764)

In very rare circumstances the JUMP opcode could be confused with the
argument of the opcode in the "then" part which doesn't end with the
JUMP opcode. This led to incorrect detection of the final JUMP opcode
and incorrect calculation of the size of the subexpression.

NOTE: Changed return value of functions _validate_inner() and
_validate_charset() in Modules/_sre/sre.c.  Now they return 0 on success,
-1 on failure, and 1 if the last op is JUMP (which usually is a failure).
Previously they returned 1 on success and 0 on failure.
(cherry picked from commit e9ac890)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@miss-islington miss-islington merged commit eb023a8 into python:3.11 Nov 3, 2022
@miss-islington miss-islington deleted the backport-e9ac890-3.11 branch November 3, 2022 07:48
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.

3 participants