Error out and print a debug message if epoch_log_read_remote doesn't manage
to return a node list.  Without this we touch possibly uninitialized memory
in get_max_nr_copies_from.

Signed-off-by: Christoph Hellwig <[email protected]>

diff --git a/sheep/ops.c b/sheep/ops.c
index a6f0670..27ca07d 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -351,10 +351,16 @@ static int local_stat_cluster(struct request *req)
                log->ctime = get_cluster_ctime();
                log->nr_nodes = epoch_log_read(epoch, (char *)log->nodes,
                                               sizeof(log->nodes));
-               if (log->nr_nodes == -1)
+               if (log->nr_nodes == -1) {
                        log->nr_nodes = epoch_log_read_remote(epoch,
                                                              (char 
*)log->nodes,
                                                              
sizeof(log->nodes));
+               }
+               if (log->nr_nodes == -1) {
+                       eprintf("Failed to read log for epoch %d\n", i);
+                       break;
+               }
+
                log->nr_copies = get_max_nr_copies_from(log->nodes, 
log->nr_nodes);
 
                rsp->data_length += sizeof(*log);
-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to