|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH for 8.1] Cope with zero-length binary values in the registry
It appears that it is legitimate for the registry to contain zero-length
binary values, so the registry access code needs to cope with them and
the settings copy code needs to allow for them too.
Reported-by: Rafal Wojdyla <omeg@xxxxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
src/xenvif/registry.c | 21 +++++++++++++++------
src/xenvif/settings.c | 3 ++-
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/xenvif/registry.c b/src/xenvif/registry.c
index f903922..23b948b 100644
--- a/src/xenvif/registry.c
+++ b/src/xenvif/registry.c
@@ -30,6 +30,7 @@
*/
#include <ntddk.h>
+#include <stdlib.h>
#include "registry.h"
#include "assert.h"
@@ -937,25 +938,30 @@ RegistryQueryBinaryValue(
if (!NT_SUCCESS(status))
goto fail4;
+ *Buffer = NULL;
+
switch (Partial->Type) {
case REG_BINARY:
+ *Length = Partial->DataLength;
+
+ if (*Length == 0)
+ break;
+
*Buffer = __RegistryAllocate(Partial->DataLength);
status = STATUS_NO_MEMORY;
if (*Buffer == NULL)
break;
- *Length = Partial->DataLength;
RtlCopyMemory(*Buffer, Partial->Data, Partial->DataLength);
break;
default:
status = STATUS_INVALID_PARAMETER;
- *Buffer = NULL;
break;
}
- if (*Buffer == NULL)
+ if (!NT_SUCCESS(status))
goto fail5;
__RegistryFree(Partial);
@@ -996,7 +1002,7 @@ RegistryUpdateBinaryValue(
goto fail1;
Partial = __RegistryAllocate(FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION,
Data) +
- Length);
+ __min(Length, 1));
status = STATUS_NO_MEMORY;
if (Partial == NULL)
@@ -1004,8 +1010,11 @@ RegistryUpdateBinaryValue(
Partial->TitleIndex = 0;
Partial->Type = REG_BINARY;
- Partial->DataLength = Length;
- RtlCopyMemory(Partial->Data, Buffer, Partial->DataLength);
+
+ if (Length != 0) {
+ Partial->DataLength = Length;
+ RtlCopyMemory(Partial->Data, Buffer, Partial->DataLength);
+ }
status = ZwSetValueKey(Key,
&Unicode,
diff --git a/src/xenvif/settings.c b/src/xenvif/settings.c
index 96b06a2..3ce4771 100644
--- a/src/xenvif/settings.c
+++ b/src/xenvif/settings.c
@@ -119,7 +119,8 @@ SettingsCopyInterfaceValue(
ValueName->Buffer,
Value,
Length);
- RegistryFreeBinaryValue(Value);
+ if (Length != 0)
+ RegistryFreeBinaryValue(Value);
}
break;
--
2.1.1
_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |