UINT64_MAX >> 2);
if (strlen(altdir) > 0) {
- char cmd[MAXNAMELEN];
- char realaltdir[MAXNAMELEN];
+ char *cmd;
+ char *realaltdir;
char *bin;
char *ztest;
char *isa;
int isalen;
- (void) realpath(getexecname(), cmd);
+ cmd = umem_alloc(MAXPATHLEN, UMEM_NOFAIL);
+ realaltdir = umem_alloc(MAXPATHLEN, UMEM_NOFAIL);
+
+ VERIFY(NULL != realpath(getexecname(), cmd));
if (0 != access(altdir, F_OK)) {
ztest_dump_core = B_FALSE;
fatal(B_TRUE, "invalid alternate ztest path: %s",
fatal(B_TRUE, "invalid alternate lib directory %s",
zo->zo_alt_libpath);
}
+
+ umem_free(cmd, MAXPATHLEN);
+ umem_free(realaltdir, MAXPATHLEN);
}
}
static void
setup_data_fd(void)
{
- char *tmp = tempnam(NULL, NULL);
- ztest_fd_data = open(tmp, O_RDWR | O_CREAT, 0700);
+ static char ztest_name_data[] = "/tmp/ztest.data.XXXXXX";
+
+ ztest_fd_data = mkstemp(ztest_name_data);
ASSERT3S(ztest_fd_data, >=, 0);
- (void) unlink(tmp);
- free(tmp);
+ (void) unlink(ztest_name_data);
}
static int
{
pid_t pid;
int status;
- char cmdbuf[MAXPATHLEN];
+ char *cmdbuf = NULL;
pid = fork();
if (cmd == NULL) {
- (void) strlcpy(cmdbuf, getexecname(), sizeof (cmdbuf));
+ cmdbuf = umem_alloc(MAXPATHLEN, UMEM_NOFAIL);
+ (void) strlcpy(cmdbuf, getexecname(), MAXPATHLEN);
cmd = cmdbuf;
}
fatal(B_TRUE, "exec failed: %s", cmd);
}
+ if (cmdbuf != NULL) {
+ umem_free(cmdbuf, MAXPATHLEN);
+ cmd = NULL;
+ }
+
while (waitpid(pid, &status, 0) != pid)
continue;
if (statusp != NULL)
char timebuf[100];
char numbuf[6];
spa_t *spa;
- char cmd[MAXNAMELEN];
+ char *cmd;
boolean_t hasalt;
int f;
char *fd_data_str = getenv("ZTEST_FD_DATA");
ASSERT3U(ztest_opts.zo_datasets, ==, ztest_shared_hdr->zh_ds_count);
/* Override location of zpool.cache */
- (void) asprintf((char **)&spa_config_path, "%s/zpool.cache",
- ztest_opts.zo_dir);
+ VERIFY(asprintf((char **)&spa_config_path, "%s/zpool.cache",
+ ztest_opts.zo_dir) != -1);
ztest_ds = umem_alloc(ztest_opts.zo_datasets * sizeof (ztest_ds_t),
UMEM_NOFAIL);
(u_longlong_t)ztest_opts.zo_time);
}
- (void) strlcpy(cmd, getexecname(), sizeof (cmd));
+ cmd = umem_alloc(MAXNAMELEN, UMEM_NOFAIL);
+ (void) strlcpy(cmd, getexecname(), MAXNAMELEN);
zs->zs_do_init = B_TRUE;
if (strlen(ztest_opts.zo_alt_ztest) != 0) {
kills, iters - kills, (100.0 * kills) / MAX(1, iters));
}
+ umem_free(cmd, MAXNAMELEN);
+
return (0);
}