From 68163e7329949f509d60c239e04e5ed7f0c6bc0e Mon Sep 17 00:00:00 2001
From: Juergen Gross <jgross@suse.com>
Date: Fri, 18 Sep 2026 12:25:07 +0200
Subject: [PATCH] tools/xenstored: fix live update with watches specifying
 depth

Due to a typo the state record for a watch specifying a depth is
written only partially. Instead of using the correct length of the
xs_state_watch_ext structure only the length of the xs_state_watch
structure was used when writing the data.

Fix that by using the correct length.

This is XSA-514 / CVE-2026-79607

Fixes: db98de120cb8 ("tools/xenstored: add depth information to watches")
Reported-by: Andrii Sultanov <andriy.sultanov@vates.tech>
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/xenstored/watch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/xenstored/watch.c b/tools/xenstored/watch.c
index c143e6fbcf..7097ab0b0d 100644
--- a/tools/xenstored/watch.c
+++ b/tools/xenstored/watch.c
@@ -354,7 +354,7 @@ const char *dump_state_watches(FILE *fp, struct connection *conn,
 			return "Dump watch state error";
 
 		if (watch->depth >= 0) {
-			if (fwrite(&swe, sizeof(sw), 1, fp) != 1)
+			if (fwrite(&swe, sizeof(swe), 1, fp) != 1)
 				return "Dump watch state ext error";
 		} else {
 			if (fwrite(&sw, sizeof(sw), 1, fp) != 1)
-- 
2.55.0

