fix(controller): set c->running in cluster_run so HA primary streams joblist/workerlist
cluster_start (which set c->running) is orphaned on the HA myapp_run path, so the running flag was never set on HA nodes — check_controller() treated the primary as shutting down and zeroed joblist/workerlist reply chunks. Own the flag lifecycle in cluster_run, symmetric with the c->running=0 on shutdown. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a735a880ae
commit
646aa69aa8
3 changed files with 47 additions and 0 deletions
|
|
@ -65,6 +65,34 @@ static void test_hostctrl_req_reject_negative_action(void)
|
|||
TEST_ASSERT_EQUAL_INT(-EINVAL, rc);
|
||||
}
|
||||
|
||||
/* init_reply_by_req must fully zero the reply so the generated
|
||||
* encode_RequestReply never reads a stale `redirect_host` pointer (and the
|
||||
* other common trailer fields) off an uninitialized stack reply. Regression
|
||||
* guard for the heap-use-after-free in encode_RequestReply / strlen seen on a
|
||||
* NOP/state-report reply whose redirect_host was stack garbage. */
|
||||
static void test_init_reply_by_req_zeroes_reply(void)
|
||||
{
|
||||
/* Poison the whole reply with non-zero bytes — mirrors an uninitialized
|
||||
* stack reply whose redirect_host happens to be a (dangling) non-NULL. */
|
||||
xce_reply_t reply;
|
||||
xce_request_t req = { .seq = 42, .opcode = OPCode_nop };
|
||||
memset(&reply, 0xFF, sizeof(reply));
|
||||
|
||||
init_reply_by_req(&reply, &req);
|
||||
|
||||
/* seq/opcode carried from the request */
|
||||
TEST_ASSERT_EQUAL_UINT64(42, reply.seq);
|
||||
TEST_ASSERT_EQUAL_INT(OPCode_nop, reply.opcode);
|
||||
|
||||
/* Trailer/common fields the encoder always reads must be cleared so a
|
||||
* handler that only sets data_which/data cannot leak garbage onto the wire
|
||||
* (or dereference a dangling redirect_host). */
|
||||
TEST_ASSERT_NULL(reply.redirect_host);
|
||||
TEST_ASSERT_EQUAL_UINT(0, reply.redirect_port);
|
||||
TEST_ASSERT_EQUAL_INT(0, reply.status);
|
||||
TEST_ASSERT_EQUAL_INT(0, reply.data_which);
|
||||
}
|
||||
|
||||
void test_request(void)
|
||||
{
|
||||
printf("\n>> host control request validation tests\n\n");
|
||||
|
|
@ -76,4 +104,5 @@ void test_request(void)
|
|||
RUN_TEST(test_hostctrl_req_reject_tag);
|
||||
RUN_TEST(test_hostctrl_req_reject_untag);
|
||||
RUN_TEST(test_hostctrl_req_reject_negative_action);
|
||||
RUN_TEST(test_init_reply_by_req_zeroes_reply);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue