static int
test_run(int i, const char *tmpdir)
{
+#ifdef PATH_MAX
+ char workdir[PATH_MAX];
+#else
char workdir[1024];
+#endif
char logfilename[64];
int failures_before = failures;
int skips_before = skips;
const char *progname;
char **saved_argv;
const char *tmp, *option_arg, *p;
- char tmpdir[256], *pwd, *testprogdir, *tmp2 = NULL, *vlevel = NULL;
- char tmpdir_timestamp[256];
+#ifdef PATH_MAX
+ char tmpdir[PATH_MAX];
+#else
+ char tmpdir[256];
+#endif
+ char *pwd, *testprogdir, *tmp2 = NULL, *vlevel = NULL;
+ char tmpdir_timestamp[32];
(void)argc; /* UNUSED */
strftime(tmpdir_timestamp, sizeof(tmpdir_timestamp),
"%Y-%m-%dT%H.%M.%S",
localtime(&now));
- sprintf(tmpdir, "%s/%s.%s-%03d", tmp, progname,
- tmpdir_timestamp, i);
+ if ((strlen(tmp) + 1 + strlen(progname) + 1 +
+ strlen(tmpdir_timestamp) + 1 + 3) >
+ (sizeof(tmpdir) / sizeof(char))) {
+ fprintf(stderr,
+ "ERROR: Temp directory pathname too long\n");
+ exit(1);
+ }
+ snprintf(tmpdir, sizeof(tmpdir), "%s/%s.%s-%03d", tmp,
+ progname, tmpdir_timestamp, i);
if (assertMakeDir(tmpdir,0755))
break;
if (i >= 999) {