Bug 1091677 - 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: mainline
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
Assignee: Lalatendu Mohanty
QA Contact:
URL:
Whiteboard:
Depends On: 1086460
Blocks: 1092037 1109180 1122290 1227808
TreeView+ depends on / blocked
 
Reported: 2014-04-27 08:48 UTC by Lalatendu Mohanty
Modified: 2015-12-01 16:45 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 1086460
: 1092037 1109180 (view as bug list)
Environment:
Last Closed: 2014-11-11 08:31:00 UTC
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:


Attachments (Terms of Use)
diff from the fix I was working on (15.57 KB, patch)
2014-05-07 12:16 UTC, Kaleb KEITHLEY
no flags Details | Diff


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

Description Lalatendu Mohanty 2014-04-27 08:48:01 UTC
+++ 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

Comment 1 Lalatendu Mohanty 2014-04-27 08:52:11 UTC
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.

Comment 2 Anand Avati 2014-05-07 10:45:56 UTC
REVIEW: http://review.gluster.org/7693 (Core: Fix issues reported by Cppcheck) posted (#1) for review on master by Lalatendu Mohanty (lmohanty@redhat.com)

Comment 3 Kaleb KEITHLEY 2014-05-07 12:16:06 UTC
Created attachment 893235 [details]
diff from the fix I was working on

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

Comment 4 Anand Avati 2014-05-20 11:52:21 UTC
REVIEW: http://review.gluster.org/7693 (Core: Fix issues reported by Cppcheck) posted (#2) for review on master by Lalatendu Mohanty (lmohanty@redhat.com)

Comment 5 Anand Avati 2014-05-20 11:53:41 UTC
REVIEW: http://review.gluster.org/7693 (Core: Fix issues reported by Cppcheck) posted (#3) for review on master by Lalatendu Mohanty (lmohanty@redhat.com)

Comment 6 Anand Avati 2014-05-29 15:29:40 UTC
REVIEW: http://review.gluster.org/7693 (Core: Fix issues reported by Cppcheck) posted (#4) for review on master by Lalatendu Mohanty (lmohanty@redhat.com)

Comment 7 Anand Avati 2014-06-12 11:20:50 UTC
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>

Comment 8 Lalatendu Mohanty 2014-06-13 11:57:22 UTC
Assigning it to Kelab, to fix issues which were not addressed in last patch.

Comment 9 Lalatendu Mohanty 2014-06-13 12:11:09 UTC
Keeping the bug in modified state as the patch is merged in master, but no build is available. Also Kelab is going fix rest of the issues in Bz 1109180.

Comment 10 Niels de Vos 2014-11-11 08:31:00 UTC
This bug is getting closed because a release has been made available that should address the reported issue. In case the problem is still not fixed with glusterfs-3.6.1, please reopen this bug report.

glusterfs-3.6.1 has been announced [1], packages for several distributions should become available in the near future. Keep an eye on the Gluster Users mailinglist [2] and the update infrastructure for your distribution.

[1] http://supercolony.gluster.org/pipermail/gluster-users/2014-November/019410.html
[2] http://supercolony.gluster.org/mailman/listinfo/gluster-users


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