Closed 313ctric closed 6 months ago
Maybe it is possible to use std::ffi::CString?
I had a look at the usbip-win source code.
strncmp
seems to only compare until the first \0
, meaning that if we return {busid}\0\0\0...
, it shouldn't be a problem.
This is consistent with the linux kernel docs, which says
Bus ID of the exported device, string closed with zero byte, e.g. "3-2". The unused bytes shall be filled with zero bytes.
From this, I'm reading that the remaining 0x00
or 0xFE
bytes are not supposed to be regarded as a part of busId
.
I think rewriting the comparison logic for strings would just be addressing the symptoms. The real bug is that we're storing bytes after the first null byte in the string, as if it was part of the busId
. I think it would be better to strip the string on creation.
Good point about just stripping the strings. This should be good now.
(may need a small chage to deal with a changed variable name, but I don't know enough about git to do merge conflicts or anything like that)
This partly fixes #3. Changes the busId check to use a null-terminated string comparison.