1
1

Merge pull request #6477 from markalle/report_bindings_strlen

opal_hwloc_base_cset2str() off-by-1 in its strncat()
Этот коммит содержится в:
Josh Hursey 2019-03-14 12:42:50 -05:00 коммит произвёл GitHub
родитель 9b91cf09cc 30d60994d2
Коммит ad8c842e7d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23

Просмотреть файл

@ -19,6 +19,7 @@
* Copyright (C) 2018 Mellanox Technologies, Ltd.
* All rights reserved.
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
* Copyright (c) 2019 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -1728,14 +1729,14 @@ int opal_hwloc_base_cset2str(char *str, int len,
for (core_index = 0; core_index < num_cores; ++core_index) {
if (map[socket_index][core_index] > 0) {
if (!first) {
strncat(str, ", ", len - strlen(str));
strncat(str, ", ", len - strlen(str) - 1);
}
first = false;
snprintf(tmp, stmp, "socket %d[core %d[hwt %s]]",
socket_index, core_index,
bitmap2rangestr(map[socket_index][core_index]));
strncat(str, tmp, len - strlen(str));
strncat(str, tmp, len - strlen(str) - 1);
}
}
}
@ -1791,7 +1792,7 @@ int opal_hwloc_base_cset2mapstr(char *str, int len,
for (socket = hwloc_get_obj_by_type(topo, HWLOC_OBJ_SOCKET, 0);
NULL != socket;
socket = socket->next_cousin) {
strncat(str, "[", len - strlen(str));
strncat(str, "[", len - strlen(str) - 1);
/* Iterate over all existing cores in this socket */
core_index = 0;
@ -1803,7 +1804,7 @@ int opal_hwloc_base_cset2mapstr(char *str, int len,
socket->cpuset,
HWLOC_OBJ_CORE, ++core_index)) {
if (core_index > 0) {
strncat(str, "/", len - strlen(str));
strncat(str, "/", len - strlen(str) - 1);
}
/* Iterate over all existing PUs in this core */
@ -1818,13 +1819,13 @@ int opal_hwloc_base_cset2mapstr(char *str, int len,
/* Is this PU in the cpuset? */
if (hwloc_bitmap_isset(cpuset, pu->os_index)) {
strncat(str, "B", len - strlen(str));
strncat(str, "B", len - strlen(str) - 1);
} else {
strncat(str, ".", len - strlen(str));
strncat(str, ".", len - strlen(str) - 1);
}
}
}
strncat(str, "]", len - strlen(str));
strncat(str, "]", len - strlen(str) - 1);
}
return OPAL_SUCCESS;