Skip to content

Commit

Permalink
Add #ifdef guards around UI_GET_SYSNAME (#218)
Browse files Browse the repository at this point in the history
If the C code is built with a kernel header that does not provide
UI_GET_SYSNAME, then ui_get_sysname() will always raise OSError.
(Unless incorrect arguments are provided to the function, in which
case the function still behaves as it otherwise would.)
  • Loading branch information
KarsMulder authored Apr 28, 2024
1 parent 5fb3190 commit cb41241
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions evdev/uinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ uinput_get_sysname(PyObject *self, PyObject *args)
int ret = PyArg_ParseTuple(args, "i", &fd);
if (!ret) return NULL;

#ifdef UI_GET_SYSNAME
if (ioctl(fd, UI_GET_SYSNAME(sizeof(sysname)), &sysname) < 0)
goto on_err;

return Py_BuildValue("s", &sysname);
#endif

on_err:
PyErr_SetFromErrno(PyExc_OSError);
Expand Down

0 comments on commit cb41241

Please sign in to comment.