Re: Bug report and fix for FTP.pm
Graham Barr (bodg@tiuk.ti.com)
Wed, 22 May 96 07:55:51 BST
David A Lee <dave@calldei.com> writes:
>I found the following problem in FTP.pm but email bounced to the owner,
>Perhaps this group is interested.
>
> ----- The following addresses have delivery notifications -----
><Grahm.Barr@tiuk.ti.com> (unrecoverable error)
>...
>550 <Grahm.Barr@tiuk.ti.com>... User unknown
You missed an a from my name <Graham.Barr@tiuk.ti.com>
^
> ----- Original message follows -----
>
>I'm using libwww-perl (lwp-request) and I had problems
>reading ftp:// url's. I tracked down the problem
>The perl error complained about use of uninitialized string
>and substr beyond end of string.
The buffer should never be uninitialized, but it could be zero length
causing substr to return undef.
>(in version 18 of Net::FTP) to this code :
>
>FTP.pm - line 839
>
> return $n
> unless($n >= 0);
>
>The problem is that if sysread() returns 0 then the next line
>doing a substr( ... ) fails because the buffer is undefined.
>I fixed this by change >= 0 to be >0 like this :
Not always true, it is possible for sysread to return 0 and the buffer
to contain a single character. It is the substr line that needs changeing
> return $n
> unless($n > 0);
>
>
Graham.
--
Graham Barr <bodg@tiuk.ti.com>
Texas Instruments Ltd.