Open
Description
char buf[1024];
Why not allocate the buffer dynamically to remove this limitation? I am passing a structure to the driver that contains, among other things, the name of the target device of size PATH_MAX, and I do not fit into 1024 bytes. Everything works in the client in C, but not in python with your module.
Activity
gst commentedon Jul 28, 2022
something like that :
?
gst commentedon Jul 28, 2022
I would be very happy to contribute and make the fix/MR by the way.
tiran commentedon Jul 29, 2022
There is even a better way that avoids the extra memory allocation. You can create a new, empty bytes object and directly access its buffer. You are allowed to do this if the object is new and has not left the scope of the current C function.
zenbooster commentedon Jul 29, 2022
I like this option better.
Also, in the fcntl_ioctl_impl function, I removed adding zero to the end of the parameter for ioctl. Removed - works.
gst commentedon Jul 29, 2022
I did it like that :)
gst commentedon Jul 29, 2022
@zenbooster
seems like we overlapped :)
not sure what is eventually best to do.
if you are ok with that : can you make a diff to my branch and I'll merge/cherry-pick the commit into it ?
arhadthedev commentedon Jul 29, 2022
Take everything of
fcntl_fcntl_impl
into gh-95429 and leavefcntl_ioctl_impl
in gh-95439?gst commentedon Jul 29, 2022
seems good for me.
so I can leave #95429 as is ?
arhadthedev commentedon Jul 29, 2022
Right. BTW I forgot to preliminary check that the only difference between the PRs in
fcntl_fcntl_impl
is in names.serhiy-storchaka commentedon Apr 24, 2025
There may be an issue with this. Currently, when you pass too small buffer, you have still a chance to get reasonable (truncated) result or OSError. When you directly pass a small buffer to fcntl() or ioctl(), you have larger chance to get a segfault or memory corruption. It is a bug in your program, but severity of it will be changed, as well as a chance for recovery.
I think that it is safer to use that technique only for large buffer, and continue to use the temporary buffer for small arguments.
7 remaining items