Bug 714042 - ccs_tool segfaults: (1) input file = output file and subcommand gets some options, (2) update gets no input file
Summary: ccs_tool segfaults: (1) input file = output file and subcommand gets some opt...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: cman
Version: 5.6
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: ---
: ---
Assignee: Jan Pokorný [poki]
QA Contact: Cluster QE
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-06-17 08:15 UTC by Attila Sragli
Modified: 2013-09-30 22:05 UTC (History)
5 users (show)

Fixed In Version: cman-2.0.115-111.el5
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-09-30 22:05:54 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Proposed patch (2.35 KB, patch)
2013-04-16 21:31 UTC, Jan Pokorný [poki]
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2013:1304 0 normal SHIPPED_LIVE cman bug fix update 2013-09-30 21:13:37 UTC

Description Attila Sragli 2011-06-17 08:15:55 UTC
Description of problem:
ccs_tool exits with Segmentation Fault while creating a new cluster config file with "ccs_tool addfence -c ... -o ... ..."

Version-Release number of selected component (if applicable):
ccs_tool 2.0.115 (built Apr 26 2011 12:47:53)

How reproducible:
Run "ccs_tool addfence" with the -c and -o switches, but without the -C switch.
  
Actual results:
The cluster config file is modified as expected, but after that the ccs_tool exits with Segmentation Fault.

Comment 1 Jan Pokorný [poki] 2012-08-02 16:03:16 UTC
Admittedly, "Red Hat Cluster Suite" product in Bugzilla is tempting,
but no longer in use (no longer having a standalone position).

As per the indicated version, flipping to RHEL 5 -- cman.
If this was not encountered on RHEL, please change to Fedora rawhide.

Core file arising from the segfault would be appreciated
(see, e.g., https://access.redhat.com/knowledge/solutions/4896).

Comment 2 RHEL Program Management 2013-02-22 19:56:21 UTC
Development Management has reviewed and declined this request.
You may appeal this decision by reopening this request.

Comment 3 Jan Pokorný [poki] 2013-03-05 15:09:17 UTC
# ccs_tool addfence -c /etc/cluster/cluster.conf \
    -o /etc/cluster/cluster.conf virt fence_virt
> running ccs_tool update...
> Segmentation fault

[...]

> #0  _getopt_internal_r
>     (argc=2, argv=0x7fffffffe730, optstring=0x40afd9 "P:", longopts=0x0,
>     longind=0x0, long_only=0, d=0x2aaaab9f79c0)
>     at getopt.c:461
> 
> #1  _getopt_internal
>     (argc=7, argv=0x7fffffffe730, optstring=0x756c632f72657473 <Address
>     0x756c632f72657473 out of bounds>, longopts=0x7, longind=0x5,
>     long_only=7)
>     at getopt.c:1136
> 
> #2  parse_args
>     (argc=2, argv=0x7fffffffe730)
>     at update.c:120
> 
> #3  update2
>     (argc=2, argv=0x7fffffffe730)
>     at update.c:194
> 
> #4  update
>     (location=<value optimized out>)
>     at update.c:171
> 
> #5  save_file
>     (doc=0x61a960, ninfo=0x7fffffffe820)
>     at editconf.c:246
> 
> #6  add_fence
>     (argc=7, argv=0x7fffffffe9a0)
>     at editconf.c:1139
> 
> #7  main
>     (argc=7, argv=<value optimized out>)
>     at ccs_tool.c:66

Problem is that there are 2+ nested independent usages of "getopt"
without resetting "optind" (+ opt{err,opt}) properly in all but the first
call (in which it is initialized implicitly by the library [1]).

Looks like a little miracle this hasn't been triggered before.


[1] http://pubs.opengroup.org/onlinepubs/7908799/xsh/getopt.html
    (The Open Group Base Specifications Issue 6 ditto)

Comment 5 RHEL Program Management 2013-04-04 12:33:49 UTC
This request was evaluated by Red Hat Product Management for inclusion
in a Red Hat Enterprise Linux release.  Product Management has
requested further review of this request by Red Hat Engineering, for
potential inclusion in a Red Hat Enterprise Linux release for currently
deployed products.  This request is not yet committed for inclusion in
a release.

Comment 6 Jan Pokorný [poki] 2013-04-16 16:53:42 UTC
Another reproducer (affected: ccs/ccs_tool:update2):

# ccs_tool update -P c:4200
Set cluster base port to 4200
Segmentation fault

-P switch not documented in built-in help, but present in man ccs_tool.

Comment 7 Jan Pokorný [poki] 2013-04-16 21:31:31 UTC
Created attachment 736552 [details]
Proposed patch

Now:

re [comment 3]:
#  ccs_tool addfence -c /etc/cluster/cluster.conf \
 -o /etc/cluster/cluster.conf virt fence_virt
running ccs_tool update...
Config file updated from version 4 to 5

re [comment 6]:
# ccs_tool update -P c:4200
Set cluster base port to 4200
Source configuration file not specified.

Failed to update config file

Comment 9 Fabio Massimo Di Nitto 2013-04-17 04:08:23 UTC
(In reply to comment #7)
> Created attachment 736552 [details]
> Proposed patch
> 
> Now:
> 
> re [comment 3]:
> #  ccs_tool addfence -c /etc/cluster/cluster.conf \
>  -o /etc/cluster/cluster.conf virt fence_virt
> running ccs_tool update...
> Config file updated from version 4 to 5
> 
> re [comment 6]:
> # ccs_tool update -P c:4200
> Set cluster base port to 4200
> Source configuration file not specified.
> 
> Failed to update config file

Patch looks good, please commit to RHEL510 branch

Comment 13 Jan Pokorný [poki] 2013-04-17 14:18:55 UTC
https://git.fedorahosted.org/cgit/cluster.git/commit/?h=RHEL510&id=d55fe105fd6c3dc5ceafb60e08880a5653440732

commit d55fe105fd6c3dc5ceafb60e08880a5653440732
Author: Jan Pokorný <jpokorny>
Date:   Wed Apr 17 15:21:54 2013 +0200

    ccs_tool: fix several segfaults
    
    (1) input file = output file and subcommand gets some options
    (2) update gets no input file
    + several overflows in case the output file was specified explicitly
      and contained, as a global path, around 255 bytes or more
    
    Signed-off-by: Jan Pokorný <jpokorny>

Comment 20 errata-xmlrpc 2013-09-30 22:05:54 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-1304.html


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