Red Hat Bugzilla – Bug 1413065
HTTP-Daemon does not support IPv6: Arg length for inet_ntoa
Last modified: 2018-04-10 04:41:34 EDT
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:
Created attachment 1240354 [details] test perl file
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.
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?
Created attachment 1241332 [details] Proposed fix
Created attachment 1241785 [details] Proposed fix
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.
Hello Petr, Can I have a test package pls. A brewbuild would do. Thanks.
Unsupported testing build is available on <http://people.redhat.com/~ppisar/perl-HTTP-Daemon-6.01-6.el7/>.
Any chance of getting this into RHEL 6?
This package is not in RHEL 6.
(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
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.
(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>.
(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.
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/
(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.
Created attachment 1327543 [details] Proposed fix to handle undefined and empty string LocalAddr
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