Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1413065

Summary: HTTP-Daemon does not support IPv6: Arg length for inet_ntoa
Product: Red Hat Enterprise Linux 7 Reporter: Deepu K S <dkochuka>
Component: perl-HTTP-DaemonAssignee: Petr Pisar <ppisar>
Status: CLOSED ERRATA QA Contact: Martin Kyral <mkyral>
Severity: medium Docs Contact: Lenka Špačková <lkuprova>
Priority: unspecified    
Version: 7.3CC: djez, dkochuka, jkejda, jorton, mkyral, ppisar
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: perl-HTTP-Daemon-6.01-7.el7 Doc Type: Release Note
Doc Text:
The *HTTP::Daemon* Perl module now supports IPv6 Previously, the *HTTP::Daemon* Perl module did not support IPv6 addresses. Consequently, when running an *HTTP::Daemon::SSL* server on an IPv6 address, the server terminated unexpectedly on an attempt to print the IPv6 address with an `Arg length for inet_ntoa` error message. With this update, the *HTTP::Daemon* module has been ported from the *IO::Socket::INET* to the *IO::Socket::IP* module. As a result, *HTTP::Daemon* handles IPv6 addresses as expected.
Story Points: ---
Clone Of:
: 1492760 (view as bug list) Environment:
Last Closed: 2018-04-10 08:41:10 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:
Bug Depends On: 1492760    
Bug Blocks: 1380363, 1420851, 1465904, 1466370, 1473612    
Attachments:
Description Flags
test perl file
none
Proposed fix
none
Proposed fix
none
Proposed fix to handle undefined and empty string LocalAddr none

Description Deepu K S 2017-01-13 14:27:18 UTC
Description of problem:
If you attempt to use perl-HTTP-Daemon package on a system with the perl-IO-Socket-INET6 package installed, you will get an error ""Bad arg length for Socket::inet_ntoa, length is 16, should be 4" at
HTTP/Daemon.pm line 48"

This has been reported with the upstream module, but it would be nice to see RedHat incorporate the fix:
https://rt.cpan.org/Public/Bug/Display.html?id=71395

Version-Release number of selected component (if applicable):
Red Hat Enterprise Linux 7.3
perl-HTTP-Daemon-6.01-5.el7.noarch

How reproducible:
Always

Steps to Reproduce:
1. Reproducer program attached (test.pl)
2.
3.

Actual results:
Getting an error "Bad arg length for Socket::inet_ntoa, length is 16, should be 4" at HTTP/Daemon.pm line 48"

Expected results:
No errors.

Additional info:

Comment 2 Deepu K S 2017-01-13 14:30:41 UTC
Created attachment 1240354 [details]
test perl file

Comment 3 Petr Pisar 2017-01-13 14:56:15 UTC
Briefly looking at the HTTP::Daemon code, I think HTTP::Daemon does not support IPv6 and it should be ported from IO::Socket::INET to IO::Socket::IP.

Comment 4 Petr Pisar 2017-01-16 13:27:39 UTC
Regarding the attached reproducer, it uses HTTP::Daemon::SSL not delivered by Red Hat. If I use HTTP-Daemon-SSL-1.04 from CPAN, I even cannot start the reproducer because it complains that "[::]" is unknown service ("unable to create web socket: Name or service not known at test.pl"). If I correct the LocalAddr to "::", then I can only get bug report from HTTP/Daemon.pm line 51 about the same Socket::inet_ntoa issue. Not line 48. How do you invoke an HTTP client?

Comment 5 Petr Pisar 2017-01-16 16:52:56 UTC
Created attachment 1241332 [details]
Proposed fix

Comment 6 Petr Pisar 2017-01-17 14:07:15 UTC
Created attachment 1241785 [details]
Proposed fix

Comment 7 Petr Pisar 2017-01-17 14:36:48 UTC
How to test:

(1) Create an HTTP::Daemon object with an IPv6 listen address and check that url() method on the object returns HTTP URL a client can connect to. E.g:

 $ perl -MHTTP::Daemon -e '$d=HTTP::Daemon->new(LocalAddr=>q{::1}) or die $@; print $d->url, qq{\n}'

Before: It reports this error:
HTTP::Daemon: Bad hostname '::1' at -e line 1.

After: It prints an URL with "::1" as a host name:
http://[::1]:34389/

You try different listen addresses like "127.0.0.1", "::", "0.0.0.0". Please note that in case of unspecified address a hostname is returned.

Comment 8 Deepu K S 2017-01-20 12:44:26 UTC
Hello Petr,

Can I have a test package pls. A brewbuild would do.

Thanks.

Comment 9 Petr Pisar 2017-01-20 12:55:41 UTC
Unsupported testing build is available on <http://people.redhat.com/~ppisar/perl-HTTP-Daemon-6.01-6.el7/>.

Comment 10 Deepu K S 2017-02-17 11:08:53 UTC
Any chance of getting this into RHEL 6?

Comment 11 Petr Pisar 2017-02-17 11:19:37 UTC
This package is not in RHEL 6.

Comment 12 Deepu K S 2017-02-22 10:51:52 UTC
(In reply to Petr Pisar from comment #11)
> This package is not in RHEL 6.

I see that /usr/share/perl5/vendor_perl/HTTP/Daemon.pm is part of perl-libwww-perl
So, any chance of getting into perl-libwww-perl? I wanted to confirm that as we are already into Prod phase 2 for RHEL 6.

If possible, I shall open up a seperate BZ for that.

Thanks

Comment 13 Petr Pisar 2017-02-22 12:20:31 UTC
You are right. The module lives in different package. But I'm reluctant to update it in RHEL-6. First the RHEL-6 HTTP::Daemon documentation clearly states that it supports IPv4 only:

  The C<HTTP::Daemon> is a subclass of C<IO::Socket::INET>

and second RHEL-6 is beyond accepting new features.

Comment 17 Petr Pisar 2017-09-18 13:52:31 UTC
(In reply to Petr Pisar from comment #16)
> This is because IO::Socket::IP behaves differently from IO::Socket::INET.
> This applies not only to empty string, but also to undef value, or invalid
> addresses like q{0.1}. None of the HTTP::Daemon, IO::Socket::IP, and
> IO::Socket::INET specifies behavior in these cases.
> 
Reported to IO-Socket-IP upstream <https://rt.cpan.org/Public/Bug/Display.html?id=123069>.

Comment 18 Petr Pisar 2017-09-18 14:57:10 UTC
(In reply to Petr Pisar from comment #16)
> I can introduce special handling for undef and empty string to behave as the
> previous implementation, but it's impossible to emulate all the other corner
> cases.
> 
Actually this does not work with perl-IO-Socket-IP-0.21-4.el7.noarch because that IO::Socket::IP cannot deal with non-existing LocalAddr argument:

$ perl -MIO::Socket::IP -e '$a=IO::Socket::IP->new(Proto=>q{tcp}, Listen=>1) or die qq{Error: $@\n}; print `ss -tnlp`'
Error: 

While it works with latest upstream IO-Socket-IP-0.39:

$ perl -MIO::Socket::IP -e '$a=IO::Socket::IP->new(Proto=>q{tcp}, Listen=>1) or die qq{Error: $@\n}; print `ss -tnlp`'
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128          *:22                       *:*                  
LISTEN     0      1           :::36309                   :::*                   users:(("perl",pid=13539,fd=3))
LISTEN     0      128         :::22                      :::*                  

This incompatibility was probably fixed in IO-Socket-IP-0.25 <https://rt.cpan.org/Public/Bug/Display.html?id=91982> and to be fixed in perl-IO-Socket-IP before we can proceed with this perl-HTTP-Daemon bug.

Comment 19 Petr Pisar 2017-09-18 15:00:32 UTC
Just a demonstration how it affects perl-HTTP-Daemon:

Patched perl-HTTP-Daemon with broken perl-IO-Socket-IP:

$ perl -Ilib -MHTTP::Daemon -e '$d=HTTP::Daemon->new() or die $@; print $d->url, qq{\n}'
Died at -e line 1.

Previous perl-HTTP-Daemon on IO::Socket-INET:

[test@rhel-7-5 HTTP-Daemon-6.01]$ perl -MHTTP::Daemon -e '$d=HTTP::Daemon->new() or die $@; print $d->url, qq{\n}'
http://rhel-7-5:41466/

Comment 21 Petr Pisar 2017-09-18 16:52:32 UTC
(In reply to Petr Pisar from comment #18)
> (In reply to Petr Pisar from comment #16)
> > I can introduce special handling for undef and empty string to behave as the
> > previous implementation, but it's impossible to emulate all the other corner
> > cases.
> > 
> Actually this does not work with perl-IO-Socket-IP-0.21-4.el7.noarch because
> that IO::Socket::IP cannot deal with non-existing LocalAddr argument:
>
[...] 
> This incompatibility was probably fixed in IO-Socket-IP-0.25
> <https://rt.cpan.org/Public/Bug/Display.html?id=91982> and to be fixed in
> perl-IO-Socket-IP before we can proceed with this perl-HTTP-Daemon bug.

Yes, it was fixed and I have fix prepared in bug #1492760. With the fixed perl-IO-Socket-IP, the special handling for empty and undefined strings works.

Comment 22 Petr Pisar 2017-09-18 16:53:43 UTC
Created attachment 1327543 [details]
Proposed fix to handle undefined and empty string LocalAddr

Comment 30 errata-xmlrpc 2018-04-10 08:41:10 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.

https://access.redhat.com/errata/RHBA-2018:0665