From d7a5b0da703d2ef2587ffb05c8ccdc1e936d1873 Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Mon, 12 Sep 2011 10:37:12 -0700
Subject: [PATCH] avod slurmctld crash on slurmdbd message unpacking problem

This should eliminate an abort reported by Sam Long when a message unpack from the slurmdbd is invalid. Based upon patch from Sam Lang.
---
 src/common/slurmdbd_defs.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/common/slurmdbd_defs.c b/src/common/slurmdbd_defs.c
index a29c5b9f2b5..458c52e7181 100644
--- a/src/common/slurmdbd_defs.c
+++ b/src/common/slurmdbd_defs.c
@@ -1666,13 +1666,19 @@ static int _handle_mult_rc_ret(uint16_t rpc_version, int read_timeout)
 		if (agent_list) {
 			ListIterator itr =
 				list_iterator_create(list_msg->my_list);
-			while((out_buf = list_next(itr))) {
-				if((rc = _unpack_return_code(
+			while ((out_buf = list_next(itr))) {
+				Buf b;
+				if ((rc = _unpack_return_code(
 					    rpc_version, out_buf))
 				    != SLURM_SUCCESS)
 					break;
 
-				free_buf(list_dequeue(agent_list));
+				if ((b = list_dequeue(agent_list))) {
+					free_buf(b);
+				} else {
+					error("slurmdbd: DBD_GOT_MULT_MSG "
+					      "unpack message error");
+				}
 			}
 			list_iterator_destroy(itr);
 		}
-- 
GitLab