Skip to contentSkip to conversation

Make xenstored EOF-safe

PATCH In review Samuel Thibault 2 participants 3 messages Nov 27, 2007 – Nov 28, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make xenstored EOF-safe

As bug 968 suggests, xenstored must properly handle EOF from clients.

From: Pavel Kankovsky <[email protected]>

tools/xenstore/xenstored_core.c +2 -2
diff -r 6fd17d0dcbcd tools/xenstore/xenstored_core.c
@@ -1266,7 +1266,7 @@ static void handle_input(struct connecti
 	if (in->inhdr) {
 		bytes = conn->read(conn, in->hdr.raw + in->used,
 				   sizeof(in->hdr) - in->used);
-		if (bytes < 0)
+		if (bytes <= 0)
 			goto bad_client;
 		in->used += bytes;
 		if (in->used != sizeof(in->hdr))
@@ -1288,7 +1288,7 @@ static void handle_input(struct connecti
 
 	bytes = conn->read(conn, in->buffer + in->used,
 			   in->hdr.msg.len - in->used);
-	if (bytes < 0)
+	if (bytes <= 0)
 		goto bad_client;
 
 	in->used += bytes;
#1 lore raw

Xen-unstable 15643 introduced this bug, but it should have been fixed satisfactorily by 15644 I think? The idea being that the read hook function is responsible for turning EOF into an explicit error with rc==-1.

-- Keir

Quoted 31 lines · Samuel Thibault

As bug 968 suggests, xenstored must properly handle EOF from clients.

From: Pavel Kankovsky <[email protected]>

diff -r 6fd17d0dcbcd tools/xenstore/xenstored_core.c

tools/xenstore/xenstored_core.c Tue Nov 27 14:56:35 2007 +0000 renamed from tools/xenstore/xenstored_core.c Tue Nov 27 12:49:16 2007 +0000 +2 -2
@@ -1266,7 +1266,7 @@ static void handle_input(struct connecti
 if (in->inhdr) {
 bytes = conn->read(conn, in->hdr.raw + in->used,
  sizeof(in->hdr) - in->used);
-  if (bytes < 0)
+  if (bytes <= 0)
 goto bad_client;
 in->used += bytes;
 if (in->used != sizeof(in->hdr))
@@ -1288,7 +1288,7 @@ static void handle_input(struct connecti
 
 bytes = conn->read(conn, in->buffer + in->used,
  in->hdr.msg.len - in->used);
- if (bytes < 0)
+ if (bytes <= 0)
 goto bad_client;
 
 in->used += bytes;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
Quoted 2 lines · Keir Fraser, le Wed 28 Nov 2007 03:34:07 +0000, a écrit :

Xen-unstable 15643 introduced this bug, but it should have been fixed satisfactorily by 15644 I think?

Aow yes, I didn't notice that "read" in new_connection was actually a parameter of that function. I closed the bug.

Samuel