Author: cgutman Date: Thu Nov 20 20:51:48 2008 New Revision: 37495
URL: http://svn.reactos.org/svn/reactos?rev=37495&view=rev Log: - Fix the status returned to NDIS when it supplies a buffer which is too small - Set BytesNeeded to the correct value - Return the correct status to NDIS if it gives us an invalid lookahead size
Modified: branches/aicom-network-fixes/drivers/network/dd/pcnet/requests.c
Modified: branches/aicom-network-fixes/drivers/network/dd/pcnet/requests.c URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/netw... ============================================================================== --- branches/aicom-network-fixes/drivers/network/dd/pcnet/requests.c [iso-8859-1] (original) +++ branches/aicom-network-fixes/drivers/network/dd/pcnet/requests.c [iso-8859-1] Thu Nov 20 20:51:48 2008 @@ -352,9 +352,9 @@ { if (CopySize > InformationBufferLength) { - *BytesNeeded = (CopySize - InformationBufferLength); + *BytesNeeded = CopySize; *BytesWritten = 0; - Status = NDIS_STATUS_BUFFER_TOO_SHORT; + Status = NDIS_STATUS_INVALID_LENGTH; } else { @@ -362,6 +362,11 @@ *BytesWritten = CopySize; *BytesNeeded = CopySize; } + } + else + { + *BytesWritten = 0; + *BytesNeeded = 0; }
NdisDprReleaseSpinLock(&Adapter->Lock); @@ -417,7 +422,7 @@ if (InformationBufferLength < sizeof(ULONG)) { *BytesRead = 0; - *BytesNeeded = sizeof(ULONG) - InformationBufferLength; + *BytesNeeded = sizeof(ULONG); Status = NDIS_STATUS_INVALID_LENGTH; break; } @@ -434,7 +439,7 @@ NDIS_PACKET_TYPE_SOURCE_ROUTING) ) { - *BytesRead = 4; + *BytesRead = sizeof(ULONG); *BytesNeeded = 0; Status = NDIS_STATUS_NOT_SUPPORTED; break; @@ -453,7 +458,7 @@ if (InformationBufferLength < sizeof(ULONG)) { *BytesRead = 0; - *BytesNeeded = sizeof(ULONG) - InformationBufferLength; + *BytesNeeded = sizeof(ULONG); Status = NDIS_STATUS_INVALID_LENGTH; break; } @@ -461,7 +466,7 @@ NdisMoveMemory(&GenericULONG, InformationBuffer, sizeof(ULONG));
if (GenericULONG > 1500) - Status = NDIS_STATUS_INVALID_LENGTH; + Status = NDIS_STATUS_INVALID_DATA; else Adapter->CurrentLookaheadSize = GenericULONG;
@@ -474,7 +479,7 @@ if ((InformationBufferLength % 6) != 0) { *BytesRead = 0; - *BytesNeeded = 0; + *BytesNeeded = InformationBufferLength + (InformationBufferLength % 6); Status = NDIS_STATUS_INVALID_LENGTH; break; }