Skip to content

Commit 0173796

Browse files
authored
Merge pull request #6482 from awlauria/indexed_datatype_overflows
Fix integer overflows with indexed datatype creation.
2 parents a14bb4b + b61e624 commit 0173796

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

ompi/datatype/ompi_datatype_create_indexed.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
1616
* Copyright (c) 2015-2017 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
18+
* Copyright (c) 2019 IBM Corporation. All rights reserved.
1819
* $COPYRIGHT$
1920
*
2021
* Additional copyrights may follow
@@ -34,8 +35,9 @@ int32_t ompi_datatype_create_indexed( int count, const int* pBlockLength, const
3435
const ompi_datatype_t* oldType, ompi_datatype_t** newType )
3536
{
3637
ompi_datatype_t* pdt;
37-
int i, dLength, endat, disp;
38-
ptrdiff_t extent;
38+
int i;
39+
ptrdiff_t extent, disp, endat;
40+
size_t dLength;
3941

4042
if( 0 == count ) {
4143
return ompi_datatype_duplicate( &ompi_mpi_datatype_null.dt, newType);
@@ -70,8 +72,9 @@ int32_t ompi_datatype_create_hindexed( int count, const int* pBlockLength, const
7072
const ompi_datatype_t* oldType, ompi_datatype_t** newType )
7173
{
7274
ompi_datatype_t* pdt;
73-
int i, dLength;
75+
int i;
7476
ptrdiff_t extent, disp, endat;
77+
size_t dLength;
7578

7679
if( 0 == count ) {
7780
*newType = ompi_datatype_create( 0 );
@@ -108,8 +111,9 @@ int32_t ompi_datatype_create_indexed_block( int count, int bLength, const int* p
108111
const ompi_datatype_t* oldType, ompi_datatype_t** newType )
109112
{
110113
ompi_datatype_t* pdt;
111-
int i, dLength, endat, disp;
112-
ptrdiff_t extent;
114+
int i;
115+
ptrdiff_t extent, disp, endat;
116+
size_t dLength;
113117

114118
ompi_datatype_type_extent( oldType, &extent );
115119
if( (count == 0) || (bLength == 0) ) {
@@ -147,8 +151,9 @@ int32_t ompi_datatype_create_hindexed_block( int count, int bLength, const ptrdi
147151
const ompi_datatype_t* oldType, ompi_datatype_t** newType )
148152
{
149153
ompi_datatype_t* pdt;
150-
int i, dLength;
154+
int i;
151155
ptrdiff_t extent, disp, endat;
156+
size_t dLength;
152157

153158
ompi_datatype_type_extent( oldType, &extent );
154159
if( (count == 0) || (bLength == 0) ) {

0 commit comments

Comments
 (0)