Bug 1092037 - 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.5.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
Assignee: Kaleb KEITHLEY
QA Contact:
URL:
Whiteboard:
Depends On: 1091677 1109180 1122290 1227808
Blocks: glusterfs-3.5.4
TreeView+ depends on / blocked
 
Reported: 2014-04-28 14:46 UTC by Kaleb KEITHLEY
Modified: 2015-12-01 16:45 UTC (History)
6 users (show)

Fixed In Version: glusterfs-3.5.4
Clone Of: 1091677
Environment:
Last Closed: 2015-06-03 21:08:01 UTC
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Embargoed:


Attachments (Terms of Use)


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

Description Kaleb KEITHLEY 2014-04-28 14:46:57 UTC
+++ 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.

Comment 1 Anand Avati 2014-04-30 11:34:22 UTC
REVIEW: http://review.gluster.org/7605 (core: fix Ubuntu code audit (cppcheck) results) posted (#2) for review on release-3.5 by Kaleb KEITHLEY (kkeithle)

Comment 2 Lalatendu Mohanty 2014-05-02 04:54:49 UTC
According to the buglifecycle , the bug state should be in POST.

http://www.gluster.org/community/documentation/index.php/Bug_report_life_cycle

Comment 3 Anand Avati 2014-05-07 14:55:28 UTC
REVIEW: http://review.gluster.org/7605 (core: fix Ubuntu code audit (cppcheck) results) posted (#3) for review on release-3.5 by Kaleb KEITHLEY (kkeithle)

Comment 4 Anand Avati 2014-05-08 12:11:00 UTC
REVIEW: http://review.gluster.org/7605 (core: fix Ubuntu code audit (cppcheck) results) posted (#4) for review on release-3.5 by Kaleb KEITHLEY (kkeithle)

Comment 5 Anand Avati 2014-05-15 13:07:44 UTC
REVIEW: http://review.gluster.org/7605 (core: fix Ubuntu code audit (cppcheck) results) posted (#5) for review on release-3.5 by Kaleb KEITHLEY (kkeithle)

Comment 6 Anand Avati 2014-05-15 13:25:08 UTC
REVIEW: http://review.gluster.org/7605 (core: fix Ubuntu code audit (cppcheck) results) posted (#6) for review on release-3.5 by Kaleb KEITHLEY (kkeithle)

Comment 7 Anand Avati 2014-05-15 18:34:02 UTC
REVIEW: http://review.gluster.org/7605 (core: fix Ubuntu code audit (cppcheck) results) posted (#7) for review on release-3.5 by Kaleb KEITHLEY (kkeithle)

Comment 8 Anand Avati 2014-05-23 11:31:59 UTC
REVIEW: http://review.gluster.org/7605 (core: fix Ubuntu code audit (cppcheck) results) posted (#8) for review on release-3.5 by Kaleb KEITHLEY (kkeithle)

Comment 9 Anand Avati 2014-05-23 11:43:24 UTC
REVIEW: http://review.gluster.org/7605 (core: fix Ubuntu code audit (cppcheck) results) posted (#9) for review on release-3.5 by Kaleb KEITHLEY (kkeithle)

Comment 10 Niels de Vos 2014-06-10 16:40:24 UTC
Moving out to 3.5.2. The patch(es) need to get merged in the master branch first.

Comment 11 Niels de Vos 2014-06-29 14:21:03 UTC
Really depends on bug 1091677 and bug 1109180 which fix these issues in master.

The patch for bug 1109180 has not been merged yet, this is a prerequisite for merging the proposed change in release-3.5.

Comment 12 Niels de Vos 2014-10-05 08:54:13 UTC
The change for mainline has not been merged yet. I'm preparing a beta for glusterfs-3.5.3 without this change. Hopefully a fix will land in time for glusterfs-3.5.4.

Comment 13 Anand Avati 2014-11-19 18:32:35 UTC
REVIEW: http://review.gluster.org/7605 (core: fix Ubuntu code audit (cppcheck) results) posted (#10) for review on release-3.5 by Kaleb KEITHLEY (kkeithle)

Comment 14 Anand Avati 2014-11-26 08:30:22 UTC
COMMIT: http://review.gluster.org/7605 committed in release-3.5 by Niels de Vos (ndevos) 
------
commit 8ae5046eb6c86840ccecefbade1695e68055de33
Author: Kaleb S. KEITHLEY <kkeithle>
Date:   Tue Apr 29 15:12:46 2014 -0400

    core: fix Ubuntu code audit (cppcheck) results
    
    See http://review.gluster.org/#/c/7583/ BZ 1086460
    
    AFAICT these are false positives:
    
    [geo-replication/src/gsyncd.c:99]: (error) Memory leak: str
    [geo-replication/src/gsyncd.c:395]: (error) Memory leak: argv
    [xlators/nfs/server/src/nlm4.c:1200]: (error) Possible null pointer dereference: fde
    
    Program exits, resource leak not an issue
    [extras/geo-rep/gsync-sync-gfid.c:105]: (error) Resource leak: fp
    
    Test program:
    [extras/test/test-ffop.c:27]: (error) Buffer overrun possible for long command line arguments.
    
    Not built:
    [xlators/cluster/ha/src/ha.c:2699]: (error) Possible null pointer dereference: priv
    
    The remainder are fixed with this change-set:
    
    [heal/src/glfs-heal.c:357]: (error) Possible null pointer dereference: remote_subvol
    [libglusterfs/src/xlator.c:648]: (error) Uninitialized variable: gfid
    [libglusterfs/src/xlator.c:649]: (error) Uninitialized variable: gfid
    [xlators/cluster/afr/src/afr-inode-write.c:469]: (error) Possible null pointer dereference: frame
    [xlators/cluster/afr/src/afr-self-heal-common.c:1704]: (error) Possible null pointer dereference: local
    [xlators/cluster/dht/src/dht-rebalance.c:1643]: (error) Possible null pointer dereference: ctx
    [xlators/cluster/stripe/src/stripe.c:4963]: (error) Possible null pointer dereference: local
    [xlators/features/changelog/src/changelog.c:1464]: (error) Possible null pointer dereference: priv
    [xlators/mgmt/glusterd/src/glusterd-geo-rep.c:1656]: (error) Possible null pointer dereference: command
    [xlators/mgmt/glusterd/src/glusterd-replace-brick.c:914]: (error) Resource leak: file
    [xlators/mgmt/glusterd/src/glusterd-replace-brick.c:998]: (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:1332]: (error) Possible null pointer dereference: handle
    [xlators/mgmt/glusterd/src/glusterd-utils.c:4706]: (error) Possible null pointer dereference: this
    [xlators/mgmt/glusterd/src/glusterd-utils.c:5613]: (error) Possible null pointer dereference: this
    [xlators/mgmt/glusterd/src/glusterd-utils.c:6342]: (error) Possible null pointer dereference: path_tokens
    [xlators/mgmt/glusterd/src/glusterd-utils.c:6343]: (error) Possible null pointer dereference: path_tokens
    [xlators/mount/fuse/src/fuse-bridge.c:4591]: (error) Uninitialized variable: finh
    [xlators/mount/fuse/src/fuse-bridge.c:3004]: (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:585]: (error) Possible null pointer dereference: iobuf
    
    Rerunning cppcheck afterwards:
    
    As before, test program:
    [extras/test/test-ffop.c:27]: (error) Buffer overrun possible for long command line arguments.
    
    As before, believed to be false positive:
    [geo-replication/src/gsyncd.c:99]: (error) Memory leak: str
    [geo-replication/src/gsyncd.c:395]: (error) Memory leak: argv
    [xlators/nfs/server/src/nlm4.c:1200]: (error) Possible null pointer dereference: fde
    
    As before, not built:
    [xlators/cluster/ha/src/ha.c:2699]: (error) Possible null pointer dereference: priv
    
    False positive after fix:
    [heal/src/glfs-heal.c:356]: (error) Possible null pointer dereference: remote_subvol
    [xlators/cluster/stripe/src/stripe.c:4963]: (error) Possible null pointer dereference: local
    
    Change-Id: Ib3029d3223f5a13e2ac386a527d64d5ffe3ecb90
    BUG: 1092037
    Signed-off-by: Kaleb S. KEITHLEY <kkeithle>
    Reviewed-on: http://review.gluster.org/7605
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Niels de Vos <ndevos>

Comment 15 Niels de Vos 2015-06-03 21:08:01 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.5.4, please reopen this bug report.

glusterfs-3.5.4 has been announced on the Gluster Packaging mailinglist [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://thread.gmane.org/gmane.comp.file-systems.gluster.packaging/2
[2] http://thread.gmane.org/gmane.comp.file-systems.gluster.user


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