Bug 1122290 - Issues reported by Cppcheck static analysis tool
Summary: Issues reported by Cppcheck static analysis tool
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: GlusterFS
Classification: Community
Component: core
Version: 3.6.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
Assignee: Kaleb KEITHLEY
QA Contact:
URL:
Whiteboard:
Depends On: 1086460 1091677 1109180 1227808
Blocks: 1092037 glusterfs-3.6.0 glusterfs-3.6.4
TreeView+ depends on / blocked
 
Reported: 2014-07-22 20:56 UTC by Kaleb KEITHLEY
Modified: 2015-12-01 16:45 UTC (History)
6 users (show)

Fixed In Version: glusterfs-3.6.4beta2
Doc Type: Bug Fix
Doc Text:
Clone Of: 1109180
Environment:
Last Closed: 2015-08-11 13:11:19 UTC
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Launchpad 1274247 None None None Never

Description Kaleb KEITHLEY 2014-07-22 20:56:49 UTC
+++ This bug was initially created as a clone of Bug #1109180 +++

+++ This bug was initially created as a clone of Bug #1091677 +++

+++ This bug was initially created as a clone of Bug #1086460 +++

We pushed the Ubuntu Server team to consider GlusterFS for inclusion in the Main repository.  This is necessary for Ubuntu to build QEMU & Samba with GlusterFS support.  Part of the process was an audit of the code.  The auditor gave a NACK response for the Main Inclusion Request (MIR) and provided a bit of feedback in a comment on the MIR bug in Launchpad:

https://bugs.launchpad.net/ubuntu/+source/glusterfs/+bug/1274247/comments/14

Until we get GlusterFS in Ubuntu Main the only way for people using Ubuntu to get QEMU or Samba with GlusterFS support will be to install from a community maintained PPA.

Thank you,

Louis Zuckerman

--- Additional comment from Lalatendu Mohanty on 2014-04-25 15:02:44 EDT ---

Changing the Severity and Priority to high as this is stopping gluster from getting in to Ubuntu Main.

--- Additional comment from Lalatendu Mohanty on 2014-04-26 13:06:24 EDT ---

Copying the Cppcheck errors, from the external bug

[api/src/glfs-fops.c:700]: (error) Possible null pointer dereference: gio
[api/src/glfs-fops.c:702]: (error) Possible null pointer dereference: frame
[rpc/rpc-transport/rdma/src/rdma.c:3074]: (error) Address of local auto-variable assigned to a function parameter.
[xlators/cluster/afr/src/afr-inode-write.c:375]: (error) Possible null pointer dereference: frame
[xlators/cluster/afr/src/afr-self-heal-common.c:1522]: (error) Possible null pointer dereference: local
[xlators/cluster/dht/src/dht-rebalance.c:1574]: (error) Possible null pointer dereference: ctx
[xlators/features/marker/utils/src/gsyncd.c:99]: (error) Memory leak: str
[xlators/features/marker/utils/src/gsyncd.c:354]: (error) Memory leak: argv
[xlators/cluster/stripe/src/stripe.c:4407]: (error) Possible null pointer dereference: local
[xlators/mgmt/glusterd/src/glusterd-mountbroker.c:675]: (error) Possible null pointer dereference: cookieswitch
[xlators/mgmt/glusterd/src/glusterd-mountbroker.c:677]: (error) Possible null pointer dereference: cookieswitch
[xlators/mgmt/glusterd/src/glusterd-replace-brick.c:924]: (error) Resource leak: file
[xlators/mgmt/glusterd/src/glusterd-replace-brick.c:1008]: (error) Resource leak: file
[xlators/mgmt/glusterd/src/glusterd-sm.c:248]: (error) Possible null pointer dereference: new_ev_ctx
[xlators/mgmt/glusterd/src/glusterd-store.c:1250]: (error) Possible null pointer dereference: handle
[xlators/mount/fuse/src/fuse-bridge.c:4432]: (error) Uninitialized variable: finh
[xlators/mgmt/glusterd/src/glusterd-utils.c:4272]: (error) Possible null pointer dereference: this
[xlators/mgmt/glusterd/src/glusterd-utils.c:5113]: (error) Possible null pointer dereference: this
[xlators/nfs/server/src/nlm4.c:1176]: (error) Possible null pointer dereference: fde
[xlators/performance/quick-read/src/quick-read.c:585]: (error) Possible null pointer dereference: iobuf
[xlators/mount/fuse/src/fuse-bridge.c:2927]: (error) Possible null pointer dereference: state
[xlators/mount/fuse/src/fuse-bridge.c:3226]: (error) Possible null pointer dereference: state
[xlators/storage/bd_map/src/bd_map.c:1504]: (error) Possible null pointer dereference: bd_fd
[xlators/storage/bd_map/src/bd_map.c:1728]: (error) Possible null pointer dereference: n_entry
[xlators/storage/bd_map/src/bd_map.c:1741]: (error) Possible null pointer dereference: n_entry

--- Additional comment from Lalatendu Mohanty on 2014-04-27 04:52:11 EDT ---

Executed Cppcheck on GlusterFS master branch. Refer below for the errors

The git repo HEAD was at "commit 6a188c6b2c95d16c1bb6391c9fcb8ef808c2141b"


[glusterfs/contrib/uuid/gen_uuid.c:369]: (warning) %ld in format string (no. 2) requires 'long *' but the argument type is 'unsigned long *'.
[glusterfs/contrib/uuid/gen_uuid.c:369]: (warning) %ld in format string (no. 3) requires 'long *' but the argument type is 'unsigned long *'.
[glusterfs/extras/geo-rep/gsync-sync-gfid.c:105]: (error) Resource leak: fp
[glusterfs/extras/test/test-ffop.c:27]: (error) Buffer overrun possible for long command line arguments.
[glusterfs/geo-replication/src/gsyncd.c:99]: (error) Memory leak: str
[glusterfs/geo-replication/src/gsyncd.c:395]: (error) Memory leak: argv
[glusterfs/libglusterfs/src/xlator.c:651]: (error) Uninitialized variable: gfid
[glusterfs/libglusterfs/src/xlator.c:652]: (error) Uninitialized variable: gfid
[glusterfs/xlators/cluster/afr/src/afr-self-heal-common.c:138]: (error) Possible null pointer dereference: __ptr
[glusterfs/xlators/cluster/afr/src/afr-self-heal-common.c:140]: (error) Possible null pointer dereference: __ptr
[glusterfs/xlators/cluster/afr/src/afr-self-heal-common.c:331]: (error) Possible null pointer dereference: __ptr
[glusterfs/xlators/cluster/dht/src/dht-rebalance.c:1719]: (error) Possible null pointer dereference: ctx
[glusterfs/xlators/cluster/ha/src/ha.c:2699]: (error) Possible null pointer dereference: priv
[glusterfs/xlators/cluster/stripe/src/stripe.c:4940]: (error) Possible null pointer dereference: local
[glusterfs/xlators/features/changelog/src/changelog.c:1464]: (error) Possible null pointer dereference: priv
[glusterfs/xlators/mgmt/glusterd/src/glusterd-geo-rep.c:1659]: (error) Possible null pointer dereference: command
[glusterfs/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c:194]: (error) Possible null pointer dereference: ctx
[glusterfs/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c:865]: (error) Possible null pointer dereference: ctx
[glusterfs/xlators/mgmt/glusterd/src/glusterd-replace-brick.c:915]: (error) Resource leak: file
[glusterfs/xlators/mgmt/glusterd/src/glusterd-replace-brick.c:999]: (error) Resource leak: file
[glusterfs/xlators/mgmt/glusterd/src/glusterd-sm.c:248]: (error) Possible null pointer dereference: new_ev_ctx
[glusterfs/xlators/mgmt/glusterd/src/glusterd-syncop.c:1408]: (error) Possible null pointer dereference: this
[glusterfs/xlators/mgmt/glusterd/src/glusterd-utils.c:5297]: (error) Possible null pointer dereference: this
[glusterfs/xlators/mgmt/glusterd/src/glusterd-utils.c:6273]: (error) Possible null pointer dereference: this
[glusterfs/xlators/mgmt/glusterd/src/glusterd-utils.c:7001]: (error) Possible null pointer dereference: path_tokens
[glusterfs/xlators/mgmt/glusterd/src/glusterd-utils.c:7002]: (error) Possible null pointer dereference: path_tokens
[glusterfs/xlators/mount/fuse/src/fuse-bridge.c:4688]: (error) Uninitialized variable: finh
[glusterfs/xlators/mount/fuse/src/fuse-bridge.c:3081]: (error) Possible null pointer dereference: state
[glusterfs/xlators/nfs/server/src/nfs-common.c:89]: (error) Dangerous usage of 'volname' (strncpy doesn't always null-terminate it).
[glusterfs/xlators/nfs/server/src/nlm4.c:1199]: (error) Possible null pointer dereference: fde
[glusterfs/xlators/performance/quick-read/src/quick-read.c:586]: (error) Possible null pointer dereference: iobuf
(information) Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

--- Additional comment from Anand Avati on 2014-05-07 06:45:56 EDT ---

REVIEW: http://review.gluster.org/7693 (Core: Fix issues reported by Cppcheck) posted (#1) for review on master by Lalatendu Mohanty (lmohanty@redhat.com)

--- Additional comment from Kaleb KEITHLEY on 2014-05-07 08:16:06 EDT ---

I ran cppcheck with --force and uncovered a lot more errors.

--- Additional comment from Anand Avati on 2014-05-20 07:52:21 EDT ---

REVIEW: http://review.gluster.org/7693 (Core: Fix issues reported by Cppcheck) posted (#2) for review on master by Lalatendu Mohanty (lmohanty@redhat.com)

--- Additional comment from Anand Avati on 2014-05-20 07:53:41 EDT ---

REVIEW: http://review.gluster.org/7693 (Core: Fix issues reported by Cppcheck) posted (#3) for review on master by Lalatendu Mohanty (lmohanty@redhat.com)

--- Additional comment from Anand Avati on 2014-05-29 11:29:40 EDT ---

REVIEW: http://review.gluster.org/7693 (Core: Fix issues reported by Cppcheck) posted (#4) for review on master by Lalatendu Mohanty (lmohanty@redhat.com)

--- Additional comment from Anand Avati on 2014-06-12 07:20:50 EDT ---

COMMIT: http://review.gluster.org/7693 committed in master by Vijay Bellur (vbellur@redhat.com) 
------
commit 115ecc8da8e79e02f23478a2b0721e783792d70e
Author: Lalatendu Mohanty <lmohanty@redhat.com>
Date:   Wed Apr 30 15:25:29 2014 +0530

    Core: Fix issues reported by Cppcheck
    
    Fixed in this patch:
    
    [glusterfs/extras/geo-rep/gsync-sync-gfid.c:105]: (error) Resource leak: fp
    [glusterfs/libglusterfs/src/xlator.c:651]: (error) Uninitialized variable: gfid
    [glusterfs/libglusterfs/src/xlator.c:652]: (error) Uninitialized variable: gfid
    [glusterfs/xlators/cluster/ha/src/ha.c:2699]: (error) Possible null pointer dereference: priv
    [glusterfs/xlators/features/changelog/src/changelog.c:1464]: (error) Possible null pointer dereference: priv
    [glusterfs/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c:865]: (error) Possible null pointer dereference: ctx
    [glusterfs/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c:194]: (error) Possible null pointer dereference: ctx
    [glusterfs/xlators/mgmt/glusterd/src/glusterd-syncop.c:1408]: (error) Possible null pointer dereference: this
    [glusterfs/xlators/mgmt/glusterd/src/glusterd-utils.c:7002]: (error) Possible null pointer dereference: path_tokens
    
    Fixed in 3.4 and 3.5 branch (http://review.gluster.org/#/c/7583/ ,
    http://review.gluster.org/#/c/7605/ will be backported in a separate patch)
    
    [glusterfs/xlators/mount/fuse/src/fuse-bridge.c:4688]: (error) Uninitialized variable: finh
    [glusterfs/xlators/mount/fuse/src/fuse-bridge.c:3081]: (error) Possible null pointer dereference: state
    [glusterfs/xlators/cluster/dht/src/dht-rebalance.c:1719]: (error) Possible null pointer dereference: ctx
    [glusterfs/xlators/cluster/stripe/src/stripe.c:4940]: (error) Possible null pointer dereference: local
    [glusterfs/xlators/mgmt/glusterd/src/glusterd-replace-brick.c:915]: (error) Resource leak: file
    [glusterfs/xlators/mgmt/glusterd/src/glusterd-replace-brick.c:999]: (error) Resource leak: file
    [glusterfs/xlators/mgmt/glusterd/src/glusterd-sm.c:248]: (error) Possible null pointer dereference: new_ev_ctx
    [glusterfs/xlators/mgmt/glusterd/src/glusterd-utils.c:5297]: (error) Possible null pointer dereference: this
    [glusterfs/xlators/mgmt/glusterd/src/glusterd-utils.c:6273]: (error) Possible null pointer dereference: this
    [glusterfs/xlators/performance/quick-read/src/quick-read.c:586]: (error) Possible null pointer dereference: iobuf
    [glusterfs/xlators/nfs/server/src/nfs-common.c:89]: (error) Dangerous usage of 'volname' (strncpy doesn't always null-terminate it).
    
    False positives
    
    [glusterfs/geo-replication/src/gsyncd.c:99]: (error) Memory leak: str
    [glusterfs/geo-replication/src/gsyncd.c:395]: (error) Memory leak: argv
    [glusterfs/xlators/nfs/server/src/nlm4.c:1199]: (error) Possible null pointer dereference: fde
    [glusterfs/xlators/mgmt/glusterd/src/glusterd-geo-rep.c:1659]: (error) Possible null pointer dereference: command
    [glusterfs/xlators/mgmt/glusterd/src/glusterd-utils.c:7001]: (error) Possible null pointer dereference: path_tokens
    
    Insignificant/Don't care
    
    [glusterfs/contrib/uuid/gen_uuid.c:369]: (warning) %ld in format string (no. 2) requires 'long *' but the argument type is 'unsigned long *'.
    [glusterfs/contrib/uuid/gen_uuid.c:369]: (warning) %ld in format string (no. 3) requires 'long *' but the argument type is 'unsigned long *'.
    [glusterfs/extras/test/test-ffop.c:27]: (error) Buffer overrun possible for long command line arguments.
    [glusterfs/xlators/cluster/afr/src/afr-self-heal-common.c:138]: (error) Possible null pointer dereference: __ptr
    [glusterfs/xlators/cluster/afr/src/afr-self-heal-common.c:140]: (error) Possible null pointer dereference: __ptr
    [glusterfs/xlators/cluster/afr/src/afr-self-heal-common.c:331]: (error) Possible null pointer dereference: __ptr
    
    Change-Id: I7696ed1a2a9553b79f9714e10210a8d563a5abd8
    BUG: 1091677
    Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com>
    Reviewed-on: http://review.gluster.org/7693
    Tested-by: Gluster Build System <jenkins@build.gluster.com>
    Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
    Reviewed-by: Vijay Bellur <vbellur@redhat.com>

--- Additional comment from Lalatendu Mohanty on 2014-06-13 07:57:22 EDT ---

Assigning it to Kelab, to fix issues which were not addressed in last patch.

--- Additional comment from Anand Avati on 2014-06-13 11:39:16 EDT ---

REVIEW: http://review.gluster.org/8064 (core: fix Ubuntu code audit (cppcheck) results) posted (#1) for review on master by Kaleb KEITHLEY (kkeithle@redhat.com)

--- Additional comment from Lalatendu Mohanty on 2014-06-16 08:16:58 EDT ---


The bug state should be "POST" according to http://www.gluster.org/community/documentation/index.php/Bug_report_life_cycle 

Hence fixing it.

Comment 1 Anand Avati 2014-07-22 21:07:18 UTC
REVIEW: http://review.gluster.org/8351 (core: fix Ubuntu code audit (cppcheck) results) posted (#1) for review on release-3.6 by Kaleb KEITHLEY (kkeithle@redhat.com)

Comment 2 Anand Avati 2014-09-03 18:16:48 UTC
REVIEW: http://review.gluster.org/8351 (core: fix Ubuntu code audit (cppcheck) results) posted (#2) for review on release-3.6 by Kaleb KEITHLEY (kkeithle@redhat.com)

Comment 3 Anand Avati 2014-09-03 18:30:41 UTC
REVIEW: http://review.gluster.org/8351 (core: fix Ubuntu code audit (cppcheck) results) posted (#3) for review on release-3.6 by Kaleb KEITHLEY (kkeithle@redhat.com)

Comment 4 Anand Avati 2014-11-19 18:25:22 UTC
REVIEW: http://review.gluster.org/8351 (core: fix Ubuntu code audit (cppcheck) results) posted (#4) for review on release-3.6 by Kaleb KEITHLEY (kkeithle@redhat.com)

Comment 5 Anand Avati 2015-06-03 13:54:56 UTC
REVIEW: http://review.gluster.org/8351 (core: fix Ubuntu code audit (cppcheck) results) posted (#5) for review on release-3.6 by Kaleb KEITHLEY (kkeithle@redhat.com)


Note You need to log in before you can comment on or make changes to this bug.