aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zfs
diff options
context:
space:
mode:
authorcao <[email protected]>2016-12-17 01:11:17 +0800
committerBrian Behlendorf <[email protected]>2016-12-16 09:11:17 -0800
commit81eb8a1fbb5dae86bebdc6c518071ae3ab062e3f (patch)
treead995fff1636bb686028e762369be2bf58e19244 /cmd/zfs
parent01017962908392b83764f29b21e687844636eed6 (diff)
Fix coverity defects: CID 147534
CID 147534: Negative array index read Reviewed-by: Giuseppe Di Natale <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: cao.xuewen <[email protected]> Closes #5467
Diffstat (limited to 'cmd/zfs')
-rw-r--r--cmd/zfs/zfs_main.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c
index 7379af280..6e818afcb 100644
--- a/cmd/zfs/zfs_main.c
+++ b/cmd/zfs/zfs_main.c
@@ -2529,7 +2529,7 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
namelen = strlen(name);
}
nameidx = us_field_index("name");
- if (namelen > cb->cb_width[nameidx])
+ if (nameidx >= 0 && namelen > cb->cb_width[nameidx])
cb->cb_width[nameidx] = namelen;
/*
@@ -2574,7 +2574,7 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
return (-1);
}
sizeidx = us_field_index(propname);
- if (sizelen > cb->cb_width[sizeidx])
+ if (sizeidx >= 0 && sizelen > cb->cb_width[sizeidx])
cb->cb_width[sizeidx] = sizelen;
if (nvlist_add_uint64(props, propname, space) != 0)