[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 3/3] Fix CodeQL warnings
- ExAllocatePoolWithTag has been deprecated with Win10 2004, use ExAllocatePoolUninitialized instead - Check return value of _strtoui64 for error condition as indicated by _UI64_MAX Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx> --- src/xenvif/fdo.c | 4 +--- src/xenvif/mac.c | 2 ++ src/xenvif/pdo.c | 16 ++++------------ src/xenvif/util.h | 4 ++++ 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/xenvif/fdo.c b/src/xenvif/fdo.c index 745f948..8067e03 100644 --- a/src/xenvif/fdo.c +++ b/src/xenvif/fdo.c @@ -1879,14 +1879,12 @@ FdoQueryDeviceRelations( Size = FIELD_OFFSET(DEVICE_RELATIONS, Objects) + (sizeof (PDEVICE_OBJECT) * __max(Count, 1)); - Relations = ExAllocatePoolWithTag(PagedPool, Size, 'FIV'); + Relations = __AllocatePoolWithTag(PagedPool, Size, 'FIV'); status = STATUS_NO_MEMORY; if (Relations == NULL) goto fail1; - RtlZeroMemory(Relations, Size); - for (ListEntry = Fdo->Dx->ListEntry.Flink; ListEntry != &Fdo->Dx->ListEntry; ListEntry = ListEntry->Flink) { diff --git a/src/xenvif/mac.c b/src/xenvif/mac.c index a89904b..f21a673 100644 --- a/src/xenvif/mac.c +++ b/src/xenvif/mac.c @@ -715,6 +715,8 @@ __MacGetSpeed( Unit = "G"; } else { Speed = _strtoui64(Buffer, &Unit, 10); + if (Speed == _UI64_MAX) + Speed = Mac->Speed; if (*Unit == '\0') Unit = "G"; diff --git a/src/xenvif/pdo.c b/src/xenvif/pdo.c index e6ffbc3..bc9b9ed 100644 --- a/src/xenvif/pdo.c +++ b/src/xenvif/pdo.c @@ -1595,14 +1595,12 @@ PdoQueryDeviceRelations( if (StackLocation->Parameters.QueryDeviceRelations.Type != TargetDeviceRelation) goto done; - Relations = ExAllocatePoolWithTag(PagedPool, sizeof (DEVICE_RELATIONS), 'FIV'); + Relations = __AllocatePoolWithTag(PagedPool, sizeof (DEVICE_RELATIONS), 'FIV'); status = STATUS_NO_MEMORY; if (Relations == NULL) goto done; - RtlZeroMemory(Relations, sizeof (DEVICE_RELATIONS)); - Relations->Count = 1; ObReferenceObject(__PdoGetDeviceObject(Pdo)); Relations->Objects[0] = __PdoGetDeviceObject(Pdo); @@ -1848,14 +1846,12 @@ PdoQueryDeviceText( goto done; } - Buffer = ExAllocatePoolWithTag(PagedPool, MAXTEXTLEN, 'FIV'); + Buffer = __AllocatePoolWithTag(PagedPool, MAXTEXTLEN, 'FIV'); status = STATUS_NO_MEMORY; if (Buffer == NULL) goto done; - RtlZeroMemory(Buffer, MAXTEXTLEN); - Text.Buffer = Buffer; Text.MaximumLength = MAXTEXTLEN; Text.Length = 0; @@ -1983,14 +1979,12 @@ PdoQueryId( goto done; } - Buffer = ExAllocatePoolWithTag(PagedPool, Id.MaximumLength, 'FIV'); + Buffer = __AllocatePoolWithTag(PagedPool, Id.MaximumLength, 'FIV'); status = STATUS_NO_MEMORY; if (Buffer == NULL) goto done; - RtlZeroMemory(Buffer, Id.MaximumLength); - Id.Buffer = Buffer; Id.Length = 0; @@ -2129,14 +2123,12 @@ PdoQueryBusInformation( UNREFERENCED_PARAMETER(Pdo); - Info = ExAllocatePoolWithTag(PagedPool, sizeof (PNP_BUS_INFORMATION), 'FIV'); + Info = __AllocatePoolWithTag(PagedPool, sizeof (PNP_BUS_INFORMATION), 'FIV'); status = STATUS_NO_MEMORY; if (Info == NULL) goto done; - RtlZeroMemory(Info, sizeof (PNP_BUS_INFORMATION)); - Info->BusTypeGuid = GUID_BUS_TYPE_INTERNAL; Info->LegacyBusType = PNPBus; Info->BusNumber = 0; diff --git a/src/xenvif/util.h b/src/xenvif/util.h index 74d0436..0df2a52 100644 --- a/src/xenvif/util.h +++ b/src/xenvif/util.h @@ -151,8 +151,12 @@ __AllocatePoolWithTag( __analysis_assume(PoolType == NonPagedPool || PoolType == PagedPool); +#if (_MSC_VER >= 1928) // VS 16.9 (EWDK 20344 or later) + Buffer = ExAllocatePoolUninitialized(PoolType, NumberOfBytes, Tag); +#else #pragma warning(suppress:28160) // annotation error Buffer = ExAllocatePoolWithTag(PoolType, NumberOfBytes, Tag); +#endif if (Buffer == NULL) return NULL; -- 2.31.1.windows.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |