Skip to content

Commit c7ad9e8

Browse files
Merge pull request #1386 from andremueiot/user/andremueiot/multiplication_converted_to_larger_type
NDIS: Harden QoS bytes calculation in netvmini control path
2 parents fbc8658 + 972ecc3 commit c7ad9e8

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

network/ndis/netvmini/6x/ctrlpath.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Module Name:
2020

2121

2222
#include "netvmin6.h"
23+
#include <ntintsafe.h>
2324
#include "ctrlpath.tmh"
2425

2526

@@ -1671,6 +1672,9 @@ Return Value:
16711672

16721673
do
16731674
{
1675+
ULONG ClassificationBytes = 0;
1676+
ULONG BytesRead = 0;
1677+
16741678
//
16751679
// Verify that the request matches our requirements.
16761680
//
@@ -1681,8 +1685,18 @@ Return Value:
16811685
//
16821686
// Request is well formed, set bytes read.
16831687
//
1684-
Method->BytesRead = NDIS_SIZEOF_QOS_PARAMETERS_REVISION_1 +
1685-
Params->NumClassificationElements * Params->ClassificationElementSize;
1688+
if (!NT_SUCCESS(RtlULongMult(Params->NumClassificationElements,
1689+
Params->ClassificationElementSize,
1690+
&ClassificationBytes)) ||
1691+
!NT_SUCCESS(RtlULongAdd(NDIS_SIZEOF_QOS_PARAMETERS_REVISION_1,
1692+
ClassificationBytes,
1693+
&BytesRead)))
1694+
{
1695+
Status = NDIS_STATUS_INVALID_LENGTH;
1696+
break;
1697+
}
1698+
1699+
Method->BytesRead = BytesRead;
16861700

16871701
Status = SetQOSParameters(Adapter, Params);
16881702
if (Status != NDIS_STATUS_SUCCESS)

0 commit comments

Comments
 (0)