Skip Menu |

This queue is for tickets about the File-Util CPAN distribution.

Report information
The Basics
Id: 85151
Status: resolved
Priority: 0/
Queue: File-Util

People
Owner: tommy [...] cpan.org
Requestors: fluca1978 [...] infinito.it
Cc:
AdminCc:

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



Subject: possible regexp error in File::Util::readlimit
Date: Thu, 9 May 2013 08:50:22 +0200
To: bug-File-Util [...] rt.cpan.org
From: Luca Ferrari <fluca1978 [...] infinito.it>
I found that the File::Util::readlimit method checks for its (numerical) argument against a \D regexp, which matches any non-digit characters, but the match is then negated, making the method to throw an error on any numerical argument. A way to produce the bug is the following: my $handle_file = new File::Util; my $max_file_size = int( 1024 * 1024 * 1024 ); $handle_file->readlimit( $max_file_size ); that produces the error trace that follows: Bad call to File::Util::readlimit(). This method can only be called with a numeric value (bytes). Non-integer numbers will be converted to integer format if specified (numbers like 5.2), but don't do that, it's inefficient. This operation aborted. Origin: This is a human error. Solution: A human must fix the programming flaw. ARG _pak = File::Util ARG bad = 1073741824 1. File::Util::_throw -called at line (1518) of /usr/local/share/perl/5.14.2/File/Util.pm -was called with args -was not called to evaluate anything 2. File::Util::readlimit -called at line (16) of test.pl -was called with args -was not called to evaluate anything and going to the source code of readlimit it shows that: sub readlimit { my $arg = _myargs( @_ ); if ( defined $arg ) { return File::Util->new()->_throw ( 'bad readlimit' => { bad => $arg } ) if $arg !~ /\D/o; $READLIMIT = $arg; } return $READLIMIT; } there is the error returning condition based on the "not" "\D". On the other hand, passing a non-numerical value to readlimit makes the routine to work, while of course the other features of File::Util will not. Hope this helps. Luca
Duplicate of bug 85141, which has been resolved: https://rt.cpan.org/Ticket/Display.html?id=85141