Skip to content

Validate effect bytes before native force-feedback upload - #262

Open
omrzk wants to merge 1 commit into
gvalkov:mainfrom
omrzk:fix/validate-upload-effect-data-261
Open

omrzk wants to merge 1 commit into
gvalkov:mainfrom
omrzk:fix/validate-upload-effect-data-261

Conversation

@omrzk

@omrzk omrzk commented Nov 5, 2026

Copy link
Copy Markdown

_input.upload_effect() calls PyBytes_AsString() and copies from its result even when conversion failed, so a non-bytes argument crashes the interpreter. Check conversion and require enough bytes for struct ff_effect before copying. Complete byte strings (including subclasses and trailing data), ioctl errors, and the InputDevice.upload_effect() serialization path retain their behavior.

Fixes #261.

Validation: all 13 new native-extension tests pass on Python 3.14. On current main, six non-bytes cases terminate subprocesses with SIGSEGV and three short-buffer cases fail; four preservation controls pass. All 20 tests outside the uinput module pass. The full suite has 24 passes and six failures because this runner has no /dev/uinput; the same six fail on clean main. Native build, wheel/sdist build, pylint error check and changed-test Ruff pass. Documentation builds with two missing ecodes_generated warnings. No actual force-feedback/input hardware was tested.

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.

_input.upload_effect() segfaults when the effect data is not bytes

1 participant