Fix coverity defects: CID 147443, 147656, 147655, 147441, 147653

coverity scan CID:147443, Type: Buffer not null terminated
coverity scan CID:147656, Type: Copy into fixed size buffer
coverity scan CID:147655, Type: Copy into fixed size buffer
coverity scan CID:147441, Type: Buffer not null terminated
coverity scan CID:147653, Type: Copy into fixed size buffer

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: liuhuang <liu.huang@zte.com.cn>
Closes #5165
This commit is contained in:
BearBabyLiu
2016-09-30 04:33:09 +08:00
committed by Brian Behlendorf
parent e8ac4557af
commit 0b78aeae92
5 changed files with 7 additions and 6 deletions
+2 -1
View File
@@ -304,7 +304,8 @@ changelist_rename(prop_changelist_t *clp, const char *src, const char *dst)
remove_mountpoint(cn->cn_handle);
(void) strlcpy(newname, dst, sizeof (newname));
(void) strcat(newname, cn->cn_handle->zfs_name + strlen(src));
(void) strlcat(newname, cn->cn_handle->zfs_name + strlen(src),
sizeof (newname));
(void) strlcpy(cn->cn_handle->zfs_name, newname,
sizeof (cn->cn_handle->zfs_name));
+1 -1
View File
@@ -425,7 +425,7 @@ differ(void *arg)
if ((ofp = fdopen(di->outputfd, "w")) == NULL) {
di->zerr = errno;
strncpy(di->errbuf, strerror(errno), sizeof (di->errbuf));
strlcpy(di->errbuf, strerror(errno), sizeof (di->errbuf));
(void) close(di->datafd);
return ((void *)-1);
}
+2 -2
View File
@@ -1107,8 +1107,8 @@ zfs_strcmp_pathname(char *name, char *cmp, int wholedisk)
dup = strdup(cmp);
dir = strtok(dup, "/");
while (dir) {
strcat(cmp_name, "/");
strcat(cmp_name, dir);
strlcat(cmp_name, "/", sizeof (cmp_name));
strlcat(cmp_name, dir, sizeof (cmp_name));
dir = strtok(NULL, "/");
}
free(dup);