[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Fail XS_DIRECTORY for paths with no children


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Wed, 6 Jan 2021 16:17:50 +0000
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Wed, 06 Jan 2021 16:19:26 +0000
  • Ironport-sdr: /jPOCG01mpy4Mhhw1awvVbbHjANOydj5cBrB8dzWljeZPGDe3kpXdc6JzYOrwT5b96PoAdv2Ex PEIP1NZ2v+ANqJr9yeEvfvok4N4E9jOEySCnujzmFZ6z2i+ibtZ9ajE/szujG+fUvx5GG6WsAd 4y9b+m8prOxsbi4+JsNNLpohM7+5/Y0WF5oHGdn4BOtvsEYe8NFQHkZnm188zQ9CI+ns08XRyl Jly8v32LpkYMGJEfrSMAx7shJo//09qGIaqpemMpbbAsNz4mGj5fatwMKr8S1Wk1vijvaWfYpN 6pY=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

When a xenstore path has no children, a response is generated which
contians only the double null terminator. Detect a 0-length response
payload and return STATUS_OBJECT_PATH_NOT_FOUND to indicate that this
path does not have any children

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xenbus/store.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/xenbus/store.c b/src/xenbus/store.c
index cbc442e..570b8b5 100644
--- a/src/xenbus/store.c
+++ b/src/xenbus/store.c
@@ -115,6 +115,7 @@ typedef struct _XENBUS_STORE_REQUEST {
 typedef struct _XENBUS_STORE_BUFFER {
     LIST_ENTRY  ListEntry;
     ULONG       Magic;
+    ULONG       Length;
     PVOID       Caller;
     CHAR        Data[1];
 } XENBUS_STORE_BUFFER, *PXENBUS_STORE_BUFFER;
@@ -1036,6 +1037,7 @@ StoreCopyPayload(
         goto fail1;
 
     Buffer->Magic = XENBUS_STORE_BUFFER_MAGIC;
+    Buffer->Length = Length;
     Buffer->Caller = Caller;
 
     RtlCopyMemory(Buffer->Data, Data, Length);
@@ -1044,7 +1046,7 @@ StoreCopyPayload(
     InsertTailList(&Context->BufferList, &Buffer->ListEntry);
     KeReleaseSpinLock(&Context->Lock, Irql);
 
-    return Buffer;        
+    return Buffer;
 
 fail1:
     Error("fail1 (%08x)\n", status);
@@ -1439,6 +1441,10 @@ StoreDirectory(
     if (Buffer == NULL)
         goto fail4;
 
+    status = STATUS_OBJECT_PATH_NOT_FOUND;
+    if (Buffer->Length == 0)
+        goto fail5;
+
     StoreFreeResponse(Response);
     ASSERT(IsZeroMemory(&Request, sizeof (XENBUS_STORE_REQUEST)));
 
@@ -1446,6 +1452,9 @@ StoreDirectory(
 
     return STATUS_SUCCESS;
 
+fail5:
+    StoreFreePayload(Context, Buffer);
+
 fail4:
 fail3:
     StoreFreeResponse(Response);
-- 
2.28.0.windows.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.