He just told me that 'NXDT_COMMAND_HEADER_SIZE was added to reflect the UsbCommandHeader struct from my codebase. No received command should ever be smaller than this. NXDT_COMMAND_SIZE was renamed to NXDT_MAX_COMMAND_SIZE for this reason.'

This commit is contained in:
Dmitry Isaenko 2020-05-10 02:56:00 +03:00
parent b1966fe3af
commit fa8e07169b

View file

@ -41,7 +41,7 @@ class NxdtUsbAbi1 {
private boolean isWindows; private boolean isWindows;
private static final int NXDT_COMMAND_SIZE = 0x1000; private static final int NXDT_MAX_COMMAND_SIZE = 0x1000;
private static final int NXDT_FILE_CHUNK_SIZE = 0x800000; private static final int NXDT_FILE_CHUNK_SIZE = 0x800000;
private static final byte ABI_VERSION = 1; private static final byte ABI_VERSION = 1;
@ -291,7 +291,7 @@ class NxdtUsbAbi1 {
* 'null' if read failed * 'null' if read failed
* */ * */
private byte[] readUsbDirective() throws Exception{ private byte[] readUsbDirective() throws Exception{
ByteBuffer readBuffer = ByteBuffer.allocateDirect(NXDT_COMMAND_SIZE); ByteBuffer readBuffer = ByteBuffer.allocateDirect(NXDT_MAX_COMMAND_SIZE);
// We can limit it to 32 bytes, but there is a non-zero chance to got OVERFLOW from libusb. // We can limit it to 32 bytes, but there is a non-zero chance to got OVERFLOW from libusb.
IntBuffer readBufTransferred = IntBuffer.allocate(1); IntBuffer readBufTransferred = IntBuffer.allocate(1);
int result; int result;