Bugzilla will be upgraded to version 5.0 on December 2, 2018. The outage period for the upgrade will start at 0:00 UTC and have a duration of 12 hours
Bug 1413065 - HTTP-Daemon does not support IPv6: Arg length for inet_ntoa [NEEDINFO]
HTTP-Daemon does not support IPv6: Arg length for inet_ntoa
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: perl-HTTP-Daemon (Show other bugs)
7.3
x86_64 Linux
unspecified Severity medium
: rc
: ---
Assigned To: Petr Pisar
Martin Kyral
Lenka Špačková
: Patch
Depends On: 1492760
Blocks: 1420851 1465904 1466370 1473612 1380363
  Show dependency treegraph
 
Reported: 2017-01-13 09:27 EST by Deepu K S
Modified: 2018-04-10 04:41 EDT (History)
6 users (show)

See Also:
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 04:41:10 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
ppisar: needinfo? (mkyral)


Attachments (Terms of Use)
test perl file (750 bytes, application/x-perl)
2017-01-13 09:30 EST, Deepu K S
no flags Details
Proposed fix (10.73 KB, patch)
2017-01-16 11:52 EST, Petr Pisar
no flags Details | Diff
Proposed fix (10.79 KB, patch)
2017-01-17 09:07 EST, Petr Pisar
no flags Details | Diff
Proposed fix to handle undefined and empty string LocalAddr (1.53 KB, patch)
2017-09-18 12:53 EDT, Petr Pisar
no flags Details | Diff


External Trackers
Tracker ID Priority Status Summary Last Updated
CPAN 123069 None None None 2017-09-18 09:52 EDT
CPAN 71395 None None None 2017-01-13 09:56 EST
CPAN 91699 None None None 2017-01-13 09:58 EST
Red Hat Product Errata RHBA-2018:0665 None None None 2018-04-10 04:41 EDT

  None (edit)
Description Deepu K S 2017-01-13 09:27:18 EST
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 09:30 EST
Created attachment 1240354 [details]
test perl file
Comment 3 Petr Pisar 2017-01-13 09:56:15 EST
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 08:27:39 EST
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 11:52 EST
Created attachment 1241332 [details]
Proposed fix
Comment 6 Petr Pisar 2017-01-17 09:07 EST
Created attachment 1241785 [details]
Proposed fix
Comment 7 Petr Pisar 2017-01-17 09:36:48 EST
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 07:44:26 EST
Hello Petr,

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

Thanks.
Comment 9 Petr Pisar 2017-01-20 07:55:41 EST
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 06:08:53 EST
Any chance of getting this into RHEL 6?
Comment 11 Petr Pisar 2017-02-17 06:19:37 EST
This package is not in RHEL 6.
Comment 12 Deepu K S 2017-02-22 05:51:52 EST
(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 07:20:31 EST
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 09:52:31 EDT
(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 10:57:10 EDT
(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 11:00:32 EDT
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 12:52:32 EDT
(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 12:53 EDT
Created attachment 1327543 [details]
Proposed fix to handle undefined and empty string LocalAddr
Comment 30 errata-xmlrpc 2018-04-10 04:41:10 EDT
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

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