# HG changeset patch # User Ivo Smits # Date 1366561963 -7200 # Node ID c4a5dbe6251342afdeefd10406bd84665c355b3d # Parent 6fcedb1030bfb9889875ff89aad0833030ea7389 USBLib: small fix in WinUSB backend bounds checking diff -r 6fcedb1030bf -r c4a5dbe62513 USBLib/Communication/WinUsb/WinUsbDevice.cs --- a/USBLib/Communication/WinUsb/WinUsbDevice.cs Sun Apr 21 18:32:04 2013 +0200 +++ b/USBLib/Communication/WinUsb/WinUsbDevice.cs Sun Apr 21 18:32:43 2013 +0200 @@ -172,7 +172,7 @@ } public unsafe override int GetDescriptor(byte descriptorType, byte index, short langId, byte[] buffer, int offset, int length) { - if (length > short.MaxValue || offset + length > buffer.Length) throw new ArgumentOutOfRangeException("length"); + if (length > short.MaxValue || offset < 0 || length < 0 || offset + length > buffer.Length) throw new ArgumentOutOfRangeException("length"); fixed (Byte* b = buffer) { if (!WinUsb_GetDescriptor(InterfaceHandles[0], descriptorType, index, (ushort)langId, (IntPtr)(b + offset), length, out length)) throw new Win32Exception(Marshal.GetLastWin32Error(), "Descriptor transfer failed");