]> xenbits.xensource.com Git - people/pauldu/xenbus.git/commitdiff
Add Type parameter to RegistryQuerySzValue()
authorPaul Durrant <paul.durrant@citrix.com>
Fri, 7 Aug 2015 12:31:16 +0000 (13:31 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Fri, 7 Aug 2015 12:31:16 +0000 (13:31 +0100)
This allows the type of any existent UpperFilters value to be verified and
brings the registry code into line with XENVIF.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
src/common/registry.c
src/common/registry.h
src/xen/system.c
src/xenbus/fdo.c
src/xenbus/filters.c
src/xenfilt/driver.c
src/xenfilt/pvdevice.c

index d6499c15b4eda56e1a1813632cec571872fd8080..b75f16b71363df6268cd6364e42652485fe5b675 100644 (file)
@@ -850,6 +850,7 @@ NTSTATUS
 RegistryQuerySzValue(
     IN  HANDLE                      Key,
     IN  PCHAR                       Name,
+    OUT PULONG                      Type OPTIONAL,
     OUT PANSI_STRING                *Array
     )
 {
@@ -911,6 +912,9 @@ RegistryQuerySzValue(
     if (*Array == NULL)
         goto fail5;
 
+    if (Type != NULL)
+        *Type = Value->Type;
+
     __RegistryFree(Value);
 
     RtlFreeUnicodeString(&Unicode);
@@ -1146,7 +1150,7 @@ RegistryQuerySystemStartOption(
     if (!NT_SUCCESS(status))
         goto fail1;
 
-    status = RegistryQuerySzValue(Key, "SystemStartOptions", &Ansi);
+    status = RegistryQuerySzValue(Key, "SystemStartOptions", NULL, &Ansi);
     if (!NT_SUCCESS(status))
         goto fail2;
 
index ef0cf91081090c1ea3d820244f8dba9a111153d7..1ac13b8e7be2cb337e45cd2db834c3e671c514ce 100644 (file)
@@ -145,6 +145,7 @@ extern NTSTATUS
 RegistryQuerySzValue(
     IN  HANDLE          Key,
     IN  PCHAR           Name,
+    OUT PULONG          Type OPTIONAL,
     OUT PANSI_STRING    *Array
     );
 
index f7be9637c4c93137d185b85c0486a17cd4f2de66..1a788ce1970878a7fb5e17c04649404788cb4d1a 100644 (file)
@@ -530,7 +530,7 @@ SystemGetStartOptions(
     if (!NT_SUCCESS(status))
         goto fail1;
 
-    status = RegistryQuerySzValue(Key, "SystemStartOptions", &Ansi);
+    status = RegistryQuerySzValue(Key, "SystemStartOptions", NULL, &Ansi);
     if (!NT_SUCCESS(status))
         goto fail2;
 
index 68d6e7688b92974d69652433cada44b5c3b2c89d..0a516a47242d87ae06cc266ed2a09e2a3d2d1403 100644 (file)
@@ -732,6 +732,7 @@ FdoSetFriendlyName(
 
     status = RegistryQuerySzValue(SoftwareKey,
                                   "DriverDesc",
+                                  NULL,
                                   &DriverDesc);
     if (!NT_SUCCESS(status))
         goto fail3;
@@ -1366,6 +1367,7 @@ FdoScan(
 
         status = RegistryQuerySzValue(ParametersKey,
                                       "SyntheticClasses",
+                                      NULL,
                                       &SyntheticClasses);
         if (!NT_SUCCESS(status))
             SyntheticClasses = NULL;
@@ -1384,6 +1386,7 @@ FdoScan(
         if (ParametersKey != NULL) {
             status = RegistryQuerySzValue(ParametersKey,
                                           "SupportedClasses",
+                                          NULL,
                                           &SupportedClasses);
             if (!NT_SUCCESS(status))
                 SupportedClasses = NULL;
index 651fcc223318a3b086138f6a03b1111d9abacbaf..8eb836befbcda3e0673774c7d2144489c383bb31 100644 (file)
@@ -72,6 +72,7 @@ FiltersInstallClass(
     HANDLE          ClassKey;
     UNICODE_STRING  Unicode;
     HANDLE          Key;
+    ULONG           Type;
     ULONG           Count;
     PANSI_STRING    Old;
     ULONG           Index;
@@ -100,8 +101,12 @@ FiltersInstallClass(
 
     Count = 0;
 
-    status = RegistryQuerySzValue(Key, "UpperFilters", &Old);
+    status = RegistryQuerySzValue(Key, "UpperFilters", &Type, &Old);
     if (NT_SUCCESS(status)) {
+        status = STATUS_INVALID_PARAMETER;
+        if (Type != REG_MULTI_SZ)
+            goto fail4;
+
         for (Index = 0; Old[Index].Buffer != NULL; Index++) {
             if (_stricmp(Old[Index].Buffer, DriverName) == 0)
                 goto done;
@@ -116,7 +121,7 @@ FiltersInstallClass(
 
     status = STATUS_NO_MEMORY;
     if (New == NULL)
-        goto fail4;
+        goto fail5;
 
     Index = 0;
     while (Index < Count) {
@@ -131,7 +136,7 @@ FiltersInstallClass(
                                    REG_MULTI_SZ,
                                    New);
     if (!NT_SUCCESS(status))
-        goto fail5;
+        goto fail6;
 
     __FiltersFree(New);
 
@@ -151,17 +156,20 @@ done:
 
     return STATUS_SUCCESS;
 
-fail5:
-    Error("fail5\n");
+fail6:
+    Error("fail6\n");
 
     __FiltersFree(New);
 
-fail4:
-    Error("fail4\n");
+fail5:
+    Error("fail5\n");
 
     if (Old != NULL)
         RegistryFreeSzValue(Old);
 
+fail4:
+    Error("fail4\n");
+
     RegistryCloseKey(Key);
 
 fail3:
@@ -193,6 +201,7 @@ FiltersUninstallClass(
     HANDLE          ClassKey;
     UNICODE_STRING  Unicode;
     HANDLE          Key;
+    ULONG           Type;
     ULONG           Count;
     PANSI_STRING    Old;
     ULONG           Index;
@@ -219,8 +228,12 @@ FiltersUninstallClass(
     if (!NT_SUCCESS(status))
         goto fail3;
 
-    status = RegistryQuerySzValue(Key, "UpperFilters", &Old);
+    status = RegistryQuerySzValue(Key, "UpperFilters", &Type, &Old);
     if (NT_SUCCESS(status)) {
+        status = STATUS_INVALID_PARAMETER;
+        if (Type != REG_MULTI_SZ)
+            goto fail4;
+
         for (Index = 0; Old[Index].Buffer != NULL; Index++) {
             if (_stricmp(Old[Index].Buffer, DriverName) == 0)
                 goto found;
@@ -238,7 +251,7 @@ found:
 
     status = STATUS_NO_MEMORY;
     if (New == NULL)
-        goto fail4;
+        goto fail5;
 
     Count = 0;
     for (Index = 0; Old[Index].Buffer != NULL; Index++) {
@@ -254,7 +267,7 @@ found:
                                    REG_MULTI_SZ,
                                    New);
     if (!NT_SUCCESS(status))
-        goto fail5;
+        goto fail6;
 
     __FiltersFree(New);
 
@@ -274,17 +287,20 @@ done:
 
     return STATUS_SUCCESS;
 
-fail5:
-    Error("fail5\n");
+fail6:
+    Error("fail6\n");
 
     __FiltersFree(New);
 
-fail4:
-    Error("fail4\n");
+fail5:
+    Error("fail5\n");
 
     if (Old != NULL)
         RegistryFreeSzValue(Old);
 
+fail4:
+    Error("fail4\n");
+
     RegistryCloseKey(Key);
 
 fail3:
index 84766dd80aa92a96d88d7a068b1897b0bb356a5b..342d2b27326f966f8c3fa973afa11cf7d32e3c9e 100644 (file)
@@ -570,6 +570,7 @@ DriverAddDevice(
 
     status = RegistryQuerySzValue(ParametersKey,
                                   DeviceID,
+                                  NULL,
                                   &Type);
     if (NT_SUCCESS(status)) {
         __DriverAcquireMutex();
index 296608c337e1dd8922a9b8ce5e45babb6b9a0288..04d8193289c84ab42a51f0266ac377c7bfec1312 100644 (file)
@@ -140,6 +140,7 @@ PvdeviceGetActive(
 
     status = RegistryQuerySzValue(ParametersKey,
                                   "ActiveDeviceID",
+                                  NULL,
                                   &Ansi);
     if (!NT_SUCCESS(status))
         goto fail1;
@@ -154,6 +155,7 @@ PvdeviceGetActive(
 
     status = RegistryQuerySzValue(ParametersKey,
                                   "ActiveInstanceID",
+                                  NULL,
                                   &Ansi);
     if (!NT_SUCCESS(status))
         goto fail2;