summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorEtienne Dechamps <[email protected]>2012-10-01 16:34:52 +0200
committerBrian Behlendorf <[email protected]>2012-10-03 13:32:48 -0700
commit6aec1cd5a674d7ee9917a75fee9a82fc97cfdf77 (patch)
treeb6707675578abc895c8d3f7c6a31a08b0a297dae /cmd
parent274091c07482773c7e81cbe70f0b46b4606048d0 (diff)
Fix ztest vdev file paths.
Currently, in several instances (but not all), ztest generates vdev file paths using a statement similar to this: snprintf(path, sizeof (path), ztest_dev_template, ...); This worked fine until 40b84e7aec6392187722e61e5a4a853b530bf60f, which changed path to be a pointer to the heap instead of an array allocated on the stack. Before this change, sizeof(path) would return the size of the array; now, it returns the size of the pointer instead. As a result, the aforementioned sprintf statement uses the wrong size and truncates the vdev file path to the first 4 or 8 bytes (depending on the architecture). Typically, with default settings, the file path will become "/tmp/zt" instead of "/test/ztest.XXX". This issue only exists in ztest_vdev_attach_detach() and ztest_fault_inject(), which explains why ztest doesn't fail right away. Signed-off-by: Brian Behlendorf <[email protected]> Issue #989
Diffstat (limited to 'cmd')
-rw-r--r--cmd/ztest/ztest.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c
index ff14c6722..4aca527e8 100644
--- a/cmd/ztest/ztest.c
+++ b/cmd/ztest/ztest.c
@@ -2567,7 +2567,7 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id)
newvd_is_spare = B_TRUE;
(void) strcpy(newpath, newvd->vdev_path);
} else {
- (void) snprintf(newpath, sizeof (newpath), ztest_dev_template,
+ (void) snprintf(newpath, MAXPATHLEN, ztest_dev_template,
zopt_dir, zopt_pool, top * leaves + leaf);
if (ztest_random(2) == 0)
newpath[strlen(newpath) - 1] = 'b';
@@ -4633,9 +4633,9 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
* write failures and random online/offline activity on leaf 0,
* and we'll write random garbage to the randomly chosen leaf.
*/
- (void) snprintf(path0, sizeof (path0), ztest_dev_template,
+ (void) snprintf(path0, MAXPATHLEN, ztest_dev_template,
zopt_dir, zopt_pool, top * leaves + zs->zs_splits);
- (void) snprintf(pathrand, sizeof (pathrand), ztest_dev_template,
+ (void) snprintf(pathrand, MAXPATHLEN, ztest_dev_template,
zopt_dir, zopt_pool, top * leaves + leaf);
vd0 = vdev_lookup_by_path(spa->spa_root_vdev, path0);
@@ -4999,7 +4999,7 @@ ztest_run_zdb(char *pool)
fp = popen(zdb, "r");
- while (fgets(zbuf, sizeof (zbuf), fp) != NULL)
+ while (fgets(zbuf, 1024, fp) != NULL)
if (zopt_verbose >= 3)
(void) printf("%s", zbuf);