diff options
| author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2018-05-22 11:28:39 +0000 |
|---|---|---|
| committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2018-05-22 11:28:39 +0000 |
| commit | 799bd0686522010a51353501cca8e00c1246d723 (patch) | |
| tree | 9ee42b629e716478ab2c804a2a1074c6d66a3aec /usr/src/lib/libzfs/common/libzfs_dataset.c | |
| parent | 8da8197608a9f1e993f8ab217c01026d6619f4b8 (diff) | |
| parent | 5ac95da7d61660aa299c287a39277cb0372be959 (diff) | |
| download | illumos-joyent-799bd0686522010a51353501cca8e00c1246d723.tar.gz | |
[illumos-gate merge]
commit 5ac95da7d61660aa299c287a39277cb0372be959
9330 stack overflow when creating a deeply nested dataset
Diffstat (limited to 'usr/src/lib/libzfs/common/libzfs_dataset.c')
| -rw-r--r-- | usr/src/lib/libzfs/common/libzfs_dataset.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/usr/src/lib/libzfs/common/libzfs_dataset.c b/usr/src/lib/libzfs/common/libzfs_dataset.c index 54018af2c6..601e46fdea 100644 --- a/usr/src/lib/libzfs/common/libzfs_dataset.c +++ b/usr/src/lib/libzfs/common/libzfs_dataset.c @@ -3429,8 +3429,22 @@ zfs_create_ancestors(libzfs_handle_t *hdl, const char *path) { int prefix; char *path_copy; + char errbuf[1024]; int rc = 0; + (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, + "cannot create '%s'"), path); + + /* + * Check that we are not passing the nesting limit + * before we start creating any ancestors. + */ + if (dataset_nestcheck(path) != 0) { + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "maximum name nesting depth exceeded")); + return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf)); + } + if (check_parents(hdl, path, NULL, B_TRUE, &prefix) != 0) return (-1); @@ -3466,6 +3480,12 @@ zfs_create(libzfs_handle_t *hdl, const char *path, zfs_type_t type, if (!zfs_validate_name(hdl, path, type, B_TRUE)) return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf)); + if (dataset_nestcheck(path) != 0) { + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "maximum name nesting depth exceeded")); + return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf)); + } + /* validate parents exist */ if (check_parents(hdl, path, &zoned, B_FALSE, NULL) != 0) return (-1); @@ -4253,6 +4273,7 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive, errbuf)); } } + if (!zfs_validate_name(hdl, target, zhp->zfs_type, B_TRUE)) return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf)); } else { |
