Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unreachable (useless) code in sre.c:_validate_inner() #117071

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

Closed
NGRsoftlab opened this issue Mar 20, 2024 · 4 comments
Closed

Unreachable (useless) code in sre.c:_validate_inner() #117071

NGRsoftlab opened this issue Mar 20, 2024 · 4 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@NGRsoftlab
Copy link
Contributor

NGRsoftlab commented Mar 20, 2024

Bug report

Bug description:

Conditions in the following lines are always false, so code will never trigger FAIL:
https://github.com/python/cpython/blob/main/Modules/_sre/sre.c#L1967
https://github.com/python/cpython/blob/main/Modules/_sre/sre.c#L1987

The code it self is like:

if (max > SRE_MAXREPEAT)
    FAIL;

where
'max' is SRE_CODE which is 4 byte unsigned int (Py_UCS4), and SRE_MAXREPEAT is the max value of SRE_CODE (and Py_UCS4).

Found by Linux Verification Center (portal.linuxtesting.ru) with SVACE.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

@NGRsoftlab NGRsoftlab added the type-bug An unexpected behavior, bug, or error label Mar 20, 2024
@serhiy-storchaka
Copy link
Member

It is not always false on 32-bit platforms.

@serhiy-storchaka serhiy-storchaka closed this as not planned Won't fix, can't repro, duplicate, stale Mar 20, 2024
@NGRsoftlab
Copy link
Contributor Author

It is not always false on 32-bit platforms.

Can you please point platform, where we can test this next time?

@serhiy-storchaka
Copy link
Member

Any 32-bit platform. SRE_MAXREPEAT is PY_SSIZE_T_MAX (= $2^{31}-1$) there.

@NGRsoftlab
Copy link
Contributor Author

Thanks, got it, it's not UINT_MAX, it's INT_MAX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant