[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 2/4] SDV: NullCheck rule
On 07/02/2022 13:15, Owen Smith wrote: Check memory allocation succeeds. Also check RtlUnicodeStringToAnsiString succeeds, though this failure is unlikely when the buffer is pre-allocated. Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx> Reviewed-by: Paul Durrant <paul@xxxxxxx> --- src/common/registry.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/common/registry.c b/src/common/registry.c index 9f5628c..b9b56e1 100644 --- a/src/common/registry.c +++ b/src/common/registry.c @@ -641,8 +641,15 @@ RegistryEnumerateValues( Ansi.MaximumLength = (USHORT)((Basic->NameLength / sizeof (WCHAR)) + sizeof (CHAR)); Ansi.Buffer = __RegistryAllocate(Ansi.MaximumLength);+ status = STATUS_NO_MEMORY;+ if (Ansi.Buffer == NULL) + goto fail6; + status = RtlUnicodeStringToAnsiString(&Ansi, &Unicode, FALSE); - ASSERT(NT_SUCCESS(status)); + if (!NT_SUCCESS(status)) { + __RegistryFree(Ansi.Buffer); + goto fail7; + }Ansi.Length = (USHORT)(strlen(Ansi.Buffer) * sizeof (CHAR)); @@ -651,7 +658,7 @@ RegistryEnumerateValues(__RegistryFree(Ansi.Buffer);if (!NT_SUCCESS(status))- goto fail6; + goto fail8; }__RegistryFree(Basic);@@ -660,6 +667,8 @@ RegistryEnumerateValues(return STATUS_SUCCESS; +fail8:+fail7: fail6: fail5: __RegistryFree(Basic);
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |