]> granicus.if.org Git - zfs/commitdiff
Illumos 5909 - ensure that shared snap names don't become too long after promotion
authorAndriy Gapon <avg@freebsd.org>
Thu, 2 Jul 2015 13:04:17 +0000 (16:04 +0300)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 6 Jul 2015 16:21:30 +0000 (09:21 -0700)
5909 ensure that shared snap names don't become too long after promotion
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george@delphix.com>
Approved by: Dan McDonald <danmcd@omniti.com>

References:
  https://www.illumos.org/issues/5909
  https://github.com/illumos/illumos-gate/commit/cb5842f

Ported-by: Andriy Gapon <avg@FreeBSD.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3550

module/zfs/dsl_dataset.c

index dacb6678e4bf04b9220e35154fd85609f3ff29ec..f382f5a07d25bb533158eb8f71e3ab8967f88814 100644 (file)
@@ -2131,12 +2131,14 @@ dsl_dataset_promote_check(void *arg, dmu_tx_t *tx)
        int err;
        uint64_t unused;
        uint64_t ss_mv_cnt;
+       size_t max_snap_len;
 
        err = promote_hold(ddpa, dp, FTAG);
        if (err != 0)
                return (err);
 
        hds = ddpa->ddpa_clone;
+       max_snap_len = MAXNAMELEN - strlen(ddpa->ddpa_clonename) - 1;
 
        if (dsl_dataset_phys(hds)->ds_flags & DS_FLAG_NOPROMOTE) {
                promote_rele(ddpa, FTAG);
@@ -2200,6 +2202,10 @@ dsl_dataset_promote_check(void *arg, dmu_tx_t *tx)
 
                /* Check that the snapshot name does not conflict */
                VERIFY0(dsl_dataset_get_snapname(ds));
+               if (strlen(ds->ds_snapname) >= max_snap_len) {
+                       err = SET_ERROR(ENAMETOOLONG);
+                       goto out;
+               }
                err = dsl_dataset_snap_lookup(hds, ds->ds_snapname, &val);
                if (err == 0) {
                        (void) strcpy(ddpa->err_ds, snap->ds->ds_snapname);