diff options
author | Kaleb S. KEITHLEY <kkeithle@redhat.com> | 2014-07-22 17:03:56 -0400 |
---|---|---|
committer | Raghavendra Bhat <raghavendra@redhat.com> | 2015-06-10 05:03:01 -0700 |
commit | 4a1a1c9945656b3197b2677dd6c2142f02ade4dc (patch) | |
tree | da6c9b4f1a8f91d7903f650d6f045660a8779946 /cli/src | |
parent | cd822f8c6f0809b1b3ac3816d98f2bfd7dd5f2c6 (diff) |
core: fix Ubuntu code audit (cppcheck) results
See also http://review.gluster.org/#/c/8064/, BZ 1109180, and
http://review.gluster.org/#/c/7693/, BZ 1091677
AFAICT these are false positives:
[geo-replication/src/gsyncd.c:100]: (error) Memory leak: str
[geo-replication/src/gsyncd.c:403]: (error) Memory leak: argv
[xlators/nfs/server/src/nlm4.c:1201]: (error) Possible null pointer dereference: fde
[xlators/cluster/afr/src/afr-self-heal-common.c:138]: (error) Possible null pointer dereference: __ptr
[xlators/cluster/afr/src/afr-self-heal-common.c:140]: (error) Possible null pointer dereference: __ptr
[xlators/cluster/afr/src/afr-self-heal-common.c:331]: (error) Possible null pointer dereference: __ptr
Test program:
[extras/test/test-ffop.c:27]: (error) Buffer overrun possible for long command line arguments.
[tests/basic/fops-sanity.c:55]: (error) Buffer overrun possible for long command line arguments.
the remainder are fixed with this change-set:
[cli/src/cli-rpc-ops.c:8883]: (error) Possible null pointer dereference: local
[cli/src/cli-rpc-ops.c:8886]: (error) Possible null pointer dereference: local
[contrib/uuid/gen_uuid.c:369]: (warning) %ld in format string (no. 2) requires 'long *' but the argument type is 'unsigned long *'.
[contrib/uuid/gen_uuid.c:369]: (warning) %ld in format string (no. 3) requires 'long *' but the argument type is 'unsigned long *'.
[xlators/cluster/dht/src/dht-rebalance.c:1734]: (error) Possible null pointer dereference: ctx
[xlators/cluster/stripe/src/stripe.c:4940]: (error) Possible null pointer dereference: local
[xlators/mgmt/glusterd/src/glusterd-geo-rep.c:1718]: (error) Possible null pointer dereference: command
[xlators/mgmt/glusterd/src/glusterd-replace-brick.c:942]: (error) Resource leak: file
[xlators/mgmt/glusterd/src/glusterd-replace-brick.c:1026]: (error) Resource leak: file
[xlators/mgmt/glusterd/src/glusterd-sm.c:249]: (error) Possible null pointer dereference: new_ev_ctx
[xlators/mgmt/glusterd/src/glusterd-snapshot.c:6917]: (error) Possible null pointer dereference: volinfo
[xlators/mgmt/glusterd/src/glusterd-utils.c:4517]: (error) Possible null pointer dereference: this
[xlators/mgmt/glusterd/src/glusterd-utils.c:6662]: (error) Possible null pointer dereference: this
[xlators/mgmt/glusterd/src/glusterd-utils.c:7708]: (error) Possible null pointer dereference: this
[xlators/mount/fuse/src/fuse-bridge.c:4687]: (error) Uninitialized variable: finh
[xlators/mount/fuse/src/fuse-bridge.c:3080]: (error) Possible null pointer dereference: state
[xlators/nfs/server/src/nfs-common.c:89]: (error) Dangerous usage of 'volname' (strncpy doesn't always null-terminate it).
[xlators/performance/quick-read/src/quick-read.c:586]: (error) Possible null pointer dereference: iobuf
Rerunning cppcheck after fixing the above:
As before, test program:
[extras/test/test-ffop.c:27]: (error) Buffer overrun possible for long command line arguments.
[tests/basic/fops-sanity.c:55]: (error) Buffer overrun possible for long command line arguments.
As before, false positive:
[geo-replication/src/gsyncd.c:100]: (error) Memory leak: str
[geo-replication/src/gsyncd.c:403]: (error) Memory leak: argv
[xlators/nfs/server/src/nlm4.c:1201]: (error) Possible null pointer dereference: fde
[xlators/cluster/afr/src/afr-self-heal-common.c:138]: (error) Possible null pointer dereference: __ptr
[xlators/cluster/afr/src/afr-self-heal-common.c:140]: (error) Possible null pointer dereference: __ptr
[xlators/cluster/afr/src/afr-self-heal-common.c:331]: (error) Possible null pointer dereference: __ptr
False positive after fix:
[xlators/performance/quick-read/src/quick-read.c:584]: (error) Possible null pointer dereference: iobuf
Change-Id: Ia5a256281156dd1df2fa900caea7694d9d0a7077
BUG: 1122290
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Reviewed-on: http://review.gluster.org/8351
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'cli/src')
-rw-r--r-- | cli/src/cli-rpc-ops.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 2bacbc96270..bf8666238bb 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -9268,11 +9268,10 @@ gf_cli_snapshot (call_frame_t *frame, xlator_t *this, if (!frame || !this || !data) goto out; - if (frame->local) { - local = frame->local; - } else { + if (!frame->local) goto out; - } + + local = frame->local; options = data; @@ -9329,7 +9328,7 @@ gf_cli_snapshot (call_frame_t *frame, xlator_t *this, ret = 0; out: - if (ret && GF_SNAP_OPTION_TYPE_STATUS == type) { + if (ret && local && GF_SNAP_OPTION_TYPE_STATUS == type) { tmp_ret = dict_get_str (local->dict, "op_err_str", &err_str); if (err_str) { cli_err ("Snapshot Status : failed: %s", err_str); |