mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-03-10 20:36:21 +03:00
cmd/ztest: avoid PATH_MAX stack allocation in ztest_get_zdb_bin() (#18085)
Calling realpath(path, buf) can trigger fortified header wrappers that allocate a PATH_MAX-sized temporary buffer on the stack, exceeding the 4 KiB frame limit on some systems. Use the heap-allocating realpath(path, NULL) form instead. Sponsored-by: ERNW Research GmbH - https://ernw-research.de/ Signed-off-by: Alexander Moch <amoch@ernw.de> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Tony Hutter <hutter2@llnl.gov>
This commit is contained in:
parent
f041375b52
commit
e72f3054e3
@ -7144,6 +7144,7 @@ static void
|
||||
ztest_get_zdb_bin(char *bin, int len)
|
||||
{
|
||||
char *zdb_path;
|
||||
char *resolved;
|
||||
/*
|
||||
* Try to use $ZDB and in-tree zdb path. If not successful, just
|
||||
* let popen to search through PATH.
|
||||
@ -7157,7 +7158,11 @@ ztest_get_zdb_bin(char *bin, int len)
|
||||
return;
|
||||
}
|
||||
|
||||
VERIFY3P(realpath(getexecname(), bin), !=, NULL);
|
||||
resolved = realpath(getexecname(), NULL);
|
||||
VERIFY3P(resolved, !=, NULL);
|
||||
strlcpy(bin, resolved, len);
|
||||
free(resolved);
|
||||
|
||||
if (strstr(bin, ".libs/ztest")) {
|
||||
strstr(bin, ".libs/ztest")[0] = '\0'; /* In-tree */
|
||||
strcat(bin, "zdb");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user