Skip to content

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented Sep 30, 2025

Passing a negative or zero size to cursor.fetchmany() made it fetch all rows instead of none.

While this could be considered a security vulnerability, it was decided to treat this issue as a regular bug as passing a non-sanitized size value in the first place is not recommended.

(cherry picked from commit bc172ee)


📚 Documentation preview 📚: https://cpython-previews--139444.org.readthedocs.build/

@picnixz
Copy link
Member Author

picnixz commented Sep 30, 2025

I'm asking for a review because we don't have the uint32_t converter in 3.13.

@picnixz picnixz changed the title [3.13] gh-139283: correctly handle size limit in cursor.fetchmany(…) (GH-139296) [3.13] gh-139283: correctly handle size limit in cursor.fetchmany(...) (GH-139296) Sep 30, 2025
@picnixz picnixz changed the title [3.13] gh-139283: correctly handle size limit in cursor.fetchmany(...) (GH-139296) [3.13] gh-139283: correctly handle size limit in cursor.fetchmany() (GH-139296) Sep 30, 2025
@picnixz
Copy link
Member Author

picnixz commented Sep 30, 2025

Oh. So conversion to negative value causes an OverflowError... and not a ValueError on 3.13. What to do. Should I prefer matching the exception type as I'm anyway manually converting or should I not?

EDIT: Considering the size_t converter actually raises a ValueError instead of an OverflowError, I'll manually handle this.

@picnixz picnixz force-pushed the backport-bc172ee-3.13 branch from beaff4c to 83c3917 Compare September 30, 2025 09:44
…hmany()` (pythonGH-139296)

Passing a negative or zero size to `cursor.fetchmany()` made it fetch all rows
instead of none.

While this could be considered a security vulnerability, it was decided to treat
this issue as a regular bug as passing a non-sanitized *size* value in the first
place is not recommended.
(cherry picked from commit bc172ee)

Co-authored-by: Bénédikt Tran <[email protected]>
@picnixz picnixz force-pushed the backport-bc172ee-3.13 branch from 83c3917 to d9c2a1f Compare September 30, 2025 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant