Skip to content

Commit 2e40224

Browse files
committed
xml: fix statically-allocated opaque backend info array
It was sized for 64bit pointers max, it's not enough on 128bits platforms such as Capability Hardware Enhanced RISC Instructions (CHERI). Use something a bit more generic but still a bit hardwired to keep things simple and statically allocatable on the stack. Thanks to Jeff Hammond for the report. Signed-off-by: Brice Goglin <[email protected]>
1 parent ea7f6ba commit 2e40224

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

include/private/xml.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ typedef struct hwloc__xml_import_state_s {
2424

2525
/* opaque data used to store backend-specific data.
2626
* statically allocated to allow stack-allocation by the common code without knowing actual backend needs.
27+
* libxml is 3 ptrs. nolibxml is 3 ptr + one int.
2728
*/
28-
char data[32];
29+
char data[4 * SIZEOF_VOID_P];
2930
} * hwloc__xml_import_state_t;
3031

3132
HWLOC_DECLSPEC int hwloc__xml_import_diff(hwloc__xml_import_state_t state, hwloc_topology_diff_t *firstdiffp);
@@ -65,8 +66,9 @@ typedef struct hwloc__xml_export_state_s {
6566

6667
/* opaque data used to store backend-specific data.
6768
* statically allocated to allow stack-allocation by the common code without knowing actual backend needs.
69+
* libxml is 1 ptr. nolibxml is 1 ptr + 2 size_t + 3 ints.
6870
*/
69-
char data[40];
71+
char data[6 * SIZEOF_VOID_P];
7072
} * hwloc__xml_export_state_t;
7173

7274
HWLOC_DECLSPEC void hwloc__xml_export_topology(hwloc__xml_export_state_t parentstate, hwloc_topology_t topology, unsigned long flags);

0 commit comments

Comments
 (0)