Commit 0ff4621
authored
Pass pointers, not slices, to libc::ioctl (#2181)
Slices are not FFI-safe.
&[u8] and &mut [u8] are *wide pointers*, which means that at the moment,
we're getting lucky because they're passed via the "ScalarPair" ABI, and
this means that passing a `&[u8]` results in passing two arguments,
`*const u8` and `usize` for pointer and length. This passes an extra
argument to ioctl, which happens to work because the extra vararg is
skipped. We're getting lucky right now, and we should explicitly pass
the pointer we meant to pass instead.
This is normally checked on `extern "C"` functions, but `ioctl` in
particular uses varargs which prevents the compiler check from
reporting.1 parent 6868489 commit 0ff4621
1 file changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
| 184 | + | |
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| |||
712 | 712 | | |
713 | 713 | | |
714 | 714 | | |
715 | | - | |
| 715 | + | |
716 | 716 | | |
717 | 717 | | |
718 | 718 | | |
| |||
751 | 751 | | |
752 | 752 | | |
753 | 753 | | |
754 | | - | |
| 754 | + | |
755 | 755 | | |
756 | 756 | | |
757 | 757 | | |
| |||
780 | 780 | | |
781 | 781 | | |
782 | 782 | | |
783 | | - | |
| 783 | + | |
784 | 784 | | |
785 | 785 | | |
786 | 786 | | |
0 commit comments