archive_string_empty(&(xar->cur_file->script));
if (rsize > 2 && b[0] == '#' && b[1] == '!') {
- char path[PATH_MAX];
size_t i, end, off;
- end = sizeof(path);
- if (end > rsize)
- end = rsize;
off = 2;
if (b[off] == ' ')
off++;
+#ifdef PATH_MAX
+ if ((rsize - off) > PATH_MAX)
+ end = off + PATH_MAX;
+ else
+#endif
+ end = rsize;
+ /* Find the end of a script path. */
for (i = off; i < end && b[i] != '\0' &&
b[i] != '\n' && b[i] != '\r' &&
b[i] != ' ' && b[i] != '\t'; i++)
- path[i - off] = b[i];
- path[i - off] = '\0';
- archive_strcpy(&(xar->cur_file->script), path);
+ ;
+ archive_strncpy(&(xar->cur_file->script), b + off,
+ i - off);
}
}
#endif
DEFINE_TEST(test_sparse_basic)
{
- char cwd[PATH_MAX+1];
+ char *cwd;
struct archive *a;
/*
* The alignment of the hole of sparse files deeply depends
/* Check if the filesystem where CWD on can
* report the number of the holes of a sparse file. */
- if (!assert(getcwd(cwd, sizeof(cwd)-1) != NULL))
+#ifdef PATH_MAX
+ cwd = getcwd(NULL, PATH_MAX);/* Solaris getcwd needs the size. */
+#else
+ cwd = getcwd(NULL, 0);
+#endif
+ if (!assert(cwd != NULL))
return;
if (!is_sparse_supported(cwd)) {
+ free(cwd);
skipping("This filesystem or platform do not support "
"the reporting of the holes of a sparse file through "
"API such as lseek(HOLE)");
verify_sparse_file2(a, "file0", sparse_file0, 5, 1);
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+ free(cwd);
}