[DRE-maint] Bug#557043: libpcap-ruby1.8: /usr/lib/ruby/1.8/pcaplet.rb:77:in `=~': wrong type Regexp (expected Pcap::Packet) (TypeError)
Clinton Gower
cg03 at g11.us
Thu Nov 19 06:07:51 UTC 2009
Package: libpcap-ruby1.8
Version: 0.6-9.1
Severity: normal
Attempting to add two Filter objects to a Pcaplet object produces the error.
I have included sample code that will reproduce the error, along with a patch to
/usr/lib/ruby/1.8/pcaplet.rb that seems to resolve the issue.
Simple code sample that reproduces the error:
#!/usr/bin/ruby
require 'pcaplet'
network = Pcaplet.new
# The first add_filter works correctly, but adding the second filter produces the error.
network.add_filter(Pcap::Filter.new('src net 192.168.0.0/24', network.capture))
network.add_filter(Pcap::Filter.new('dst port 80', network.capture))
network.close
exit(0)
Line 77 in pcaplet.rb uses a regular expression to check to see if @filter an empty string.
If @filter is empty, then it is set to f. If f was a Filter object, then when =~ is
used on @filter in the next add_filter call, it expects a Packet to come after the =~
operator and fails.
The solution I found is to sanitize the f variable and make sure it is a string before
it gets assigned to initialize the @filter variable. This is done by moving line 80 up,
to before the if statement on line 77.
The patch I used on the /usr/lib/ruby/1.8/pcaplet.rb file is as follows:
76a77
> f = f.source if f.is_a? Filter
80d80
< f = f.source if f.is_a? Filter
After applying the patch, both Filter objects are successfully added without error.
Regards,
Clinton Gower
-- System Information:
Debian Release: sid
APT prefers transitional
APT policy: (500, 'transitional'), (500, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.31-1-amd64 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages libpcap-ruby1.8 depends on:
ii libc6 2.10.1-5 GNU C Library: Shared libraries
ii libpcap0.8 1.0.0-4 system interface for user-level pa
ii libruby1.8 1.8.7.174-2 Libraries necessary to run Ruby 1.
Versions of packages libpcap-ruby1.8 recommends:
ii libpcap-ruby 0.6-9.1 Ruby interface for the libpcap pac
libpcap-ruby1.8 suggests no packages.
-- no debconf information
More information about the Pkg-ruby-extras-maintainers
mailing list