Skip to content

Conversation

@markalle
Copy link
Contributor

I think the strncat() calls here need to be of the form
strncat(str, new_str_to_add, len - strlen(new_str_to_addstr) - 1);
since in the OMPI calls len is being used as total number of bytes
in str.

strncat(dest,src,n) on the other hand is documented as writing up to
n chars from the incoming string plus 1 for the null, for n+1 total
bytes it can write.

Signed-off-by: Mark Allen [email protected]
(cherry picked from commit 30d6099)

Conflicts:
opal/mca/hwloc/base/hwloc_base_util.c

I think the strncat() calls here need to be of the form
    strncat(str, new_str_to_add, len - strlen(new_str_to_addstr) - 1);
since in the OMPI calls len is being used as total number of bytes
in str.

strncat(dest,src,n) on the other hand is documented as writing up to
n chars from the incoming string plus 1 for the null, for n+1 total
bytes it can write.

Signed-off-by: Mark Allen <[email protected]>
(cherry picked from commit 30d6099)

Conflicts:
	opal/mca/hwloc/base/hwloc_base_util.c
@markalle
Copy link
Contributor Author

cherry pick from #6477

@jsquyres jsquyres added this to the v3.1.4 milestone Mar 14, 2019
@jsquyres jsquyres changed the title opal_hwloc_base_cset2str() off-by-1 in its strncat() v3.1.x: opal_hwloc_base_cset2str() off-by-1 in its strncat() Mar 14, 2019
@jsquyres jsquyres merged commit 16dbc83 into open-mpi:v3.1.x Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants