]> granicus.if.org Git - zfs/commitdiff
Fix coverity defects: CID 147654, 147690
authorGeLiXin <ge.lixin@zte.com.cn>
Thu, 13 Oct 2016 21:02:07 +0000 (05:02 +0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 13 Oct 2016 21:02:07 +0000 (14:02 -0700)
coverity scan CID:147654,type: Copy into fixed size buffer
- string operation may write past the end of the fixed-size
  destination buffer

coverity scan CID:147690,type: Uninitialized scalar variable
- call zfs_prop_get first in case we use sourcetype and
  share_sourcetype without initialization

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: GeLiXin <ge.lixin@zte.com.cn>
Closes #5253

lib/libzfs/libzfs_changelist.c
lib/libzfs/libzfs_sendrecv.c

index ed11bb8227bcc9dce49ce3c3f15e6cbc6e00e3f5..397f278727dfbf04ebc1dc66594467158dd829bb 100644 (file)
@@ -397,8 +397,8 @@ change_one(zfs_handle_t *zhp, void *data)
        char property[ZFS_MAXPROPLEN];
        char where[64];
        prop_changenode_t *cn;
-       zprop_source_t sourcetype;
-       zprop_source_t share_sourcetype;
+       zprop_source_t sourcetype = ZPROP_SRC_NONE;
+       zprop_source_t share_sourcetype = ZPROP_SRC_NONE;
 
        /*
         * We only want to unmount/unshare those filesystems that may inherit
index 55131369e0491b49a076633123e2b1d6daa12cbe..21d67e74d391c3c2393b18a7ff4e178e7865cbea 100644 (file)
@@ -3213,7 +3213,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
        /*
         * Determine name of destination snapshot.
         */
-       (void) strcpy(destsnap, tosnap);
+       (void) strlcpy(destsnap, tosnap, sizeof (destsnap));
        (void) strlcat(destsnap, chopprefix, sizeof (destsnap));
        free(cp);
        if (!zfs_name_valid(destsnap, ZFS_TYPE_SNAPSHOT)) {