From 61cd402d5155490228d7e1ab84c430c33b50f773 Mon Sep 17 00:00:00 2001 From: David Bowler Date: Tue, 10 Feb 2026 10:46:45 +0000 Subject: [PATCH] Fixed potential array overflow in alloc_recv_array The variable nreq passed to MPI_Recv was allocated as an array with the wrong size, but can be simple integer as it is passed to a blocking receive. --- src/UpdateInfo_module.f90 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/UpdateInfo_module.f90 b/src/UpdateInfo_module.f90 index a01788096..f835b50c2 100644 --- a/src/UpdateInfo_module.f90 +++ b/src/UpdateInfo_module.f90 @@ -1300,6 +1300,8 @@ end subroutine CommMat_send_data !! Changing MPI tag to conform to standard !! 2019/11/14 tsuyoshi !! Added InfoGlob in dummy arguments, and removed glob2node_old + !! 2026/02/10 10:45 dave + !! Bug fix: changed nreq to single integer (used in block receive) !! SOURCE !! subroutine alloc_recv_array(InfoGlob,irecv_array,irecv2_array,recv_array, & @@ -1334,7 +1336,7 @@ subroutine alloc_recv_array(InfoGlob,irecv_array,irecv2_array,recv_array, & logical :: flag_find_old ! -- process 2. -- ! integer :: ind_nnd,ibeg,isize,inode_send - integer :: tag,ierr,nreq(MPI_STATUS_SIZE) + integer :: tag,ierr,nreq integer, allocatable :: isort_node(:),irecv_array(:) ! -- process 3. -- ! integer :: iprim_remote,isize1,isize2,ia,nalpha,nj,njbeta,iglob_local @@ -1477,7 +1479,7 @@ subroutine alloc_recv_array(InfoGlob,irecv_array,irecv2_array,recv_array, & !! /----- DEBUG ------ !! call MPI_recv(irecv_array(ibeg),isize,MPI_INTEGER,inode_send-1,tag, & - MPI_COMM_WORLD,nreq(nnd),ierr) + MPI_COMM_WORLD,nreq,ierr) if (ierr.NE.MPI_SUCCESS) call cq_abort('Error receiving irecv_array: ', nnd, ierr) enddo endif