Skip Menu |

This queue is for tickets about the HTTP-Daemon CPAN distribution.

Report information
The Basics
Id: 125242
Status: resolved
Priority: 0/
Queue: HTTP-Daemon

People
Owner: Nobody in particular
Requestors: markus [...] wernig.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Attachments


Subject: sockhostname called on literal $addr instead of $self crashes HTTP::Daemon-6.0.1
Date: Mon, 30 Apr 2018 14:30:51 +0200
To: bug-HTTP-Daemon [...] rt.cpan.org
From: Markus Wernig <markus [...] wernig.net>
Hi all A bug seems to have slipped in with the patch to move from IO::Socket::INET to ::IP (Extend IO::Socket::IP to replace ::INET - https://rt.cpan.org/Public/Bug/Display.html?id=91699). In sub url, line 64, the "sockhostname" method is called on the result ($addr) of $self->sockaddr (called on line 52). But $addr is not a class object, but a binary string, so this must fail, and actually does with this error: Can't call method "sockhostname" without a package or object reference at /usr/share/perl5/vendor_perl/HTTP/Daemon.pm line 64. The following patch fixes this: --- Daemon.pm.dist 2018-04-30 09:31:17.902832206 +0200 +++ Daemon.pm 2018-04-30 14:17:47.502075060 +0200 @@ -61,7 +61,7 @@ $url .= '[' . inet_ntop(AF_INET6, $addr) . ']'; } else { - my $host = $addr->sockhostname; + my $host = $self->sockhostname; if (!defined $host) { if (sockaddr_family($addr) eq AF_INET6) { $host = '[' . inet_ntop(AF_INET6, $addr) . ']'; Noticed this on CentOS, after upgrading from perl-HTTP-Daemon-6.01-5.el7.noarch to perl-HTTP-Daemon-6.01-7.el7.noarch. Both Daemon.pm files report $VERSION="6.01", but the one from 5.el7 ISA IO::Socket::INET, while the other one ISA IO::Socket::IP. Regards /markus -- Markus Wernig Unix/Network Security Engineer PGP: D9203D2A4AD9FC3333DEEF9DF7ACC6208E82E4DC SIP/XMPP: markus@wernig.net Furch D25-SR Cut - Ovation CE C2078AX-5 ------------------------------------------- https://xfer.ch - https://markus.wernig.net -------------------------------------------
Download smime.p7s
application/pkcs7-signature 4k

Message body not shown because it is not plain text.

Dne Po 30.dub.2018 08:37:15, markus@wernig.net napsal(a): Show quoted text
> Hi all > > A bug seems to have slipped in with the patch to move from > IO::Socket::INET to ::IP (Extend IO::Socket::IP to replace ::INET - > https://rt.cpan.org/Public/Bug/Display.html?id=91699). >
There is still an error if the daemon is bound to an IPv6 specific non-local address. Attached patch fixes both the issues.
Subject: HTTP-Daemon-6.01-Resolve-specific-socket-addresses-correctly.patch
From e49f553aa8be21e5df72452e50af2e9f0b82ecad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com> Date: Wed, 23 May 2018 17:31:42 +0200 Subject: [PATCH] Resolve specific socket addresses correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous code did not formatted specific (not 0.0.0.0 or ::) correctly: $ perl -MHTTP::Daemon -e '$d=HTTP::Daemon->new(LocalAddr=>q{127.0.0.2}) or die; print $d->url, qq{\n}' Can't call method "sockhostname" without a package or object reference at /usr/share/perl5/vendor_perl/HTTP/Daemon.pm line 64. This patch also fixes formatting numerical IPv6 addresses. It seems that IO::Socket::IP::sockhostname() formats unresolvable addresses too. Signed-off-by: Petr Písař <ppisar@redhat.com> --- lib/HTTP/Daemon.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/HTTP/Daemon.pm b/lib/HTTP/Daemon.pm index 1e9d48e..216c73f 100644 --- a/lib/HTTP/Daemon.pm +++ b/lib/HTTP/Daemon.pm @@ -61,12 +61,23 @@ sub url $url .= '[' . inet_ntop(AF_INET6, $addr) . ']'; } else { - my $host = $addr->sockhostname; + my $host = $self->sockhostname; + # sockhostname() seems to return a stringified IP address if not + # resolvable, then quote it for a port separator and an IPv6 zone separator. + # But be paranoid for a case when it already contains a bracket. + if (defined $host and $host =~ /:/) { + if ($host =~ /[\[\]]/) { + $host = undef; + } else { + $host =~ s/%/%25/g; + $host = '[' . $host . ']'; + } + } if (!defined $host) { if (sockaddr_family($addr) eq AF_INET6) { $host = '[' . inet_ntop(AF_INET6, $addr) . ']'; } else { - $host = inet_ntop(AF_INET6, $addr); + $host = inet_ntop(AF_INET, $addr); } } $url .= $host; -- 2.14.3
On Mon Apr 30 08:37:15 2018, markus@wernig.net wrote: Show quoted text
> Hi all > > A bug seems to have slipped in with the patch to move from > IO::Socket::INET to ::IP (Extend IO::Socket::IP to replace ::INET - > https://rt.cpan.org/Public/Bug/Display.html?id=91699). > > In sub url, line 64, the "sockhostname" method is called on the result > ($addr) of $self->sockaddr (called on line 52). But $addr is not a class > object, but a binary string, so this must fail, and actually does with > this error: > > Can't call method "sockhostname" without a package or object reference > at /usr/share/perl5/vendor_perl/HTTP/Daemon.pm line 64. > > The following patch fixes this: > > --- Daemon.pm.dist 2018-04-30 09:31:17.902832206 +0200 > +++ Daemon.pm 2018-04-30 14:17:47.502075060 +0200 > @@ -61,7 +61,7 @@ > $url .= '[' . inet_ntop(AF_INET6, $addr) . ']'; > } > else { > - my $host = $addr->sockhostname; > + my $host = $self->sockhostname; > if (!defined $host) { > if (sockaddr_family($addr) eq AF_INET6) { > $host = '[' . inet_ntop(AF_INET6, $addr) . ']'; >
I've just tripped over this one as well. The fix above sorted the issue for me. Paul