From f34ddcceda45a1eae1c917804921d124584a2cea Mon Sep 17 00:00:00 2001 From: Tim Wickberg <tim@schedmd.com> Date: Wed, 15 Jun 2016 11:41:07 -0400 Subject: [PATCH] Avoid xmalloc(0) when unpacking the job_info_msg structure. Any access to this would be out of range. ASAN reports this as a two-word leak (due to allocaction[-2] and [-1] being used for xmalloc header info). --- src/common/slurm_protocol_pack.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/slurm_protocol_pack.c b/src/common/slurm_protocol_pack.c index 81203c2ab6f..cd42996e44f 100644 --- a/src/common/slurm_protocol_pack.c +++ b/src/common/slurm_protocol_pack.c @@ -5391,8 +5391,9 @@ _unpack_job_info_msg(job_info_msg_t ** msg, Buf buffer, safe_unpack32(&((*msg)->record_count), buffer); safe_unpack_time(&((*msg)->last_update), buffer); - job = (*msg)->job_array = xmalloc(sizeof(job_info_t) * - (*msg)->record_count); + if ((*msg)->record_count) + job = (*msg)->job_array = xmalloc(sizeof(job_info_t) * + (*msg)->record_count); /* load individual job info */ for (i = 0; i < (*msg)->record_count; i++) { if (_unpack_job_info_members(&job[i], buffer, -- GitLab