diff options
author | GeLiXin <[email protected]> | 2016-10-01 06:47:57 +0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-09-30 15:47:57 -0700 |
commit | 470f12d631764d3706e2702762e9f3ae924cab43 (patch) | |
tree | 894fe812a83384879dbd595744c35c275f482709 /module | |
parent | ed3ea30fb9341c860c94bf71e771f115ee4801ea (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 'module')
-rwxr-xr-x[-rw-r--r--] | module/nvpair/nvpair.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c index 071923ea7..14b196d96 100644..100755 --- a/module/nvpair/nvpair.c +++ b/module/nvpair/nvpair.c @@ -1260,6 +1260,8 @@ nvpair_type_is_array(nvpair_t *nvp) static int nvpair_value_common(nvpair_t *nvp, data_type_t type, uint_t *nelem, void *data) { + int value_sz; + if (nvp == NULL || nvpair_type(nvp) != type) return (EINVAL); @@ -1289,8 +1291,9 @@ nvpair_value_common(nvpair_t *nvp, data_type_t type, uint_t *nelem, void *data) #endif if (data == NULL) return (EINVAL); - bcopy(NVP_VALUE(nvp), data, - (size_t)i_get_value_size(type, NULL, 1)); + if ((value_sz = i_get_value_size(type, NULL, 1)) < 0) + return (EINVAL); + bcopy(NVP_VALUE(nvp), data, (size_t)value_sz); if (nelem != NULL) *nelem = 1; break; |