Mercurial > hg > ucis.core
changeset 36:c4a5dbe62513
USBLib: small fix in WinUSB backend bounds checking
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Sun, 21 Apr 2013 18:32:43 +0200 |
parents | 6fcedb1030bf |
children | 2e3f57f326b3 |
files | USBLib/Communication/WinUsb/WinUsbDevice.cs |
diffstat | 1 files changed, 1 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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");