Skip to content

Commit 0746b2e

Browse files
authored
Merge pull request #6208 from jsquyres/pr/info-get-fix
info_get: ensure to copy all requested characters
2 parents 4944508 + 9b88e60 commit 0746b2e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

opal/util/info.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ static void opal_info_get_nolock (opal_info_t *info, const char *key, int valuel
106106
* Set the flag and value
107107
*/
108108
*flag = 1;
109-
opal_string_copy(value, search->ie_value, valuelen);
109+
// Note: we copy exactly (valuelen) characters, because that's
110+
// what the caller asked for. Don't use opal_string_copy()
111+
// here, because that will guarantee to \0-terminate what is
112+
// copied (i.e., potentially copy (valuelen-1) chars and then
113+
// an additional \0). Instead: copy over exactly (valuelen)
114+
// characters, and if that's not \0-terminated, then so be it.
115+
memcpy(value, search->ie_value, valuelen);
110116
}
111117
}
112118

0 commit comments

Comments
 (0)