aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libzpool
diff options
context:
space:
mode:
authorGeLiXin <[email protected]>2016-10-01 06:47:57 +0800
committerBrian Behlendorf <[email protected]>2016-09-30 15:47:57 -0700
commit470f12d631764d3706e2702762e9f3ae924cab43 (patch)
tree894fe812a83384879dbd595744c35c275f482709 /lib/libzpool
parented3ea30fb9341c860c94bf71e771f115ee4801ea (diff)
Fix coverity defects: CID 147531 147532 147533 147535
coverity scan CID:147531,type: Argument cannot be negative - may copy data with negative size coverity scan CID:147532,type: resource leaks - may close a fd which is negative coverity scan CID:147533,type: resource leaks - may call pwrite64 with a negative size coverity scan CID:147535,type: resource leaks - may call fdopen with a negative fd Reviewed-by: Richard Laager <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: GeLiXin <[email protected]> Closes #5176
Diffstat (limited to 'lib/libzpool')
-rwxr-xr-x[-rw-r--r--]lib/libzpool/kernel.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/libzpool/kernel.c b/lib/libzpool/kernel.c
index 7ac505a64..60dda39a8 100644..100755
--- a/lib/libzpool/kernel.c
+++ b/lib/libzpool/kernel.c
@@ -668,7 +668,11 @@ vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3)
* FREAD and FWRITE to the corresponding O_RDONLY, O_WRONLY, and O_RDWR.
*/
fd = open64(realpath, flags - FREAD, mode);
- err = errno;
+ if (fd == -1) {
+ err = errno;
+ free(realpath);
+ return (err);
+ }
if (flags & FCREAT)
(void) umask(old_umask);
@@ -691,9 +695,6 @@ vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3)
free(realpath);
- if (fd == -1)
- return (err);
-
if (fstat64_blk(fd, &st) == -1) {
err = errno;
close(fd);
@@ -740,7 +741,7 @@ vn_rdwr(int uio, vnode_t *vp, void *addr, ssize_t len, offset_t offset,
if (uio == UIO_READ) {
rc = pread64(vp->v_fd, addr, len, offset);
- if (vp->v_dump_fd != -1) {
+ if (vp->v_dump_fd != -1 && rc != -1) {
int status;
status = pwrite64(vp->v_dump_fd, addr, rc, offset);
ASSERT(status != -1);