Bug 1364692

Summary: jwhois segfaults when /etc/jwhois.conf is not accessible
Product: [Fedora] Fedora EPEL Reporter: Christopher Arnold <carnold>
Component: jwhoisAssignee: Vitezslav Crhonek <vcrhonek>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: epel7CC: redhat-bugzilla, vcrhonek
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: jwhois-4.0-45.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-08-23 19:23:15 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Fixed jwhois fclose patch none

Description Christopher Arnold 2016-08-06 09:46:21 UTC
Created attachment 1188131 [details]
Fixed jwhois fclose patch

Description of problem:
When jwhois.conf is not accessible, /usr/bin/jwhois segfaults. This appears to be the result of attempting to erroneously fclose() a null FILE pointer. This is mostly observed in chrooted environments.

Version-Release number of selected component (if applicable):
$ rpm -qa | grep jwhois
jwhois-4.0-44.el7.centos.x86_64
jwhois-debuginfo-4.0-44.el7.x86_64


How reproducible:
Yes

Steps to Reproduce:
1. Install jwhois package
2. Remove /etc/jwhois.conf or otherwise make open("/etc/jwhois.conf", "r") fail
3. `jwhois example.com`

# yum install jwhois -q -y && rm -f /etc/jwhois.conf && ulimit -c unlimited && jwhois example.com
Segmentation fault (core dumped)
#


Actual results:
jwhois segfaults;

 (gdb) bt full
 #0  _IO_new_fclose (fp=0x0) at iofclose.c:54
         status = <optimized out>
 #1  0x0000000000404100 in parse_args (argc=argc@entry=0x7ffd58936eac,
     argv=argv@entry=0x7ffd58936ea0) at init.c:286
         optch = <optimized out>
         option_index = 32583
         ret = 0xa <Address 0xa out of bounds>
         in = <optimized out>
 #2  0x00000000004020e8 in main (argc=2, argv=0x7ffd58937008) at jwhois.c:95
         optind = <optimized out>
         count = 0
         ret = 0
         rc = 0
         qstring = 0x0
         text = 0x7ffd58936f30 ""
         idn = 0x7ffd58936f40 ""
         wq = {host = 0x0, port = 0, query = 0x0, domain = 0x0}



Expected results:
whois text printed to stdout

Additional info:
It looks like the issue is within jwhois-4.0-fclose.patch which has an fclose call outside the scope of the proceeding null pointer check. I was able to rebuild the sRPM with the attached patch, which appears to correct the issue. I have selected el7, since that applies to the package I replicated the issue with; however, the issue was originally observed on a system which uses el6, and I would expect any RPM with this patch applied to be affected.

Comment 1 Vitezslav Crhonek 2016-08-08 11:16:02 UTC
Hello Christopher,

Thanks for the bug report and investigation, your conclusion is correct indeed.

Fixed in EPEL7 and in Fedora Rawhide.

Comment 2 Fedora Update System 2016-08-08 11:26:37 UTC
jwhois-4.0-45.el7 has been submitted as an update to Fedora EPEL 7. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-db9b2232e4

Comment 3 Fedora Update System 2016-08-09 02:19:22 UTC
jwhois-4.0-45.el7 has been pushed to the Fedora EPEL 7 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-db9b2232e4

Comment 4 Fedora Update System 2016-08-23 19:23:12 UTC
jwhois-4.0-45.el7 has been pushed to the Fedora EPEL 7 stable repository. If problems still persist, please make note of it in this bug report.