libgeom: Fix segfault in 32-on-64 case

We were using strtoul() to parse object identifiers, which are kernel
pointers.  This works fine as long as the kernel and userland match,
but in a 32-bit libgeom on a 64-bit kernel this will return ULONG_MAX
for all objects, resulting in memory corruption when we later pick the
wrong object while resolving consumer-producer references.

MFC after:	1 week
PR:		292127
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D54452
This commit is contained in:
Dag-Erling Smørgrav
2026-01-03 10:09:51 +01:00
parent f86148d277
commit 27894e20f1
+2 -2
View File
@@ -76,10 +76,10 @@ StartElement(void *userData, const char *name, const char **attr)
ref = NULL;
for (i = 0; attr[i] != NULL; i += 2) {
if (!strcmp(attr[i], "id")) {
id = (void *)strtoul(attr[i + 1], NULL, 0);
id = (void *)strtoumax(attr[i + 1], NULL, 0);
mt->nident++;
} else if (!strcmp(attr[i], "ref")) {
ref = (void *)strtoul(attr[i + 1], NULL, 0);
ref = (void *)strtoumax(attr[i + 1], NULL, 0);
} else
printf("%*.*s[%s = %s]\n",
mt->level + 1, mt->level + 1, "",