[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Gluestik: CNbyte_count() bug?



Hi Pierre,
On 5 Jan 2013 at 3:28, Pierre Ton-That wrote:
> 
> Still working on the Litchi. Doing fine with STinG but some still some 
> problems with Gluestick. The hang with no responding ftp sites is solved 
> (connection test with calling directly MiNTnet). The next issue is that 
> some downloads are not complete, as if the last data block (more than 
> 32KB, less than 70 KB) could not be managed.
> 
> I'm not familiar with C, but looking in the Gluestik sources at 
> http://highwire.atari-users.net/cgi-bin/cvsweb/freemint/tools/gluestik/?cvsroo
> t=FreeMiNT&sortby=rev#dirlist
> 
> gs_stik.c:
> static int16 do_CNbyte_count (struct CNbyte_count_param p) { return 
> gs_canread (p.fd); }
> 
> gs_func.c:
> long gs_canread (int fd) { ... }
> 
> Is this a bug? I'm from GFA, so "long" is 32bits, and "int16", well, 
> 16bits... Correct me, but I understand gs_canread() can return a byte 
> number greater than 32767, and the result is a negative value 
> interpreted as an error.
> 
It certainly looks like a bug.  The 32-bit return value from gs_canread()
will be truncated to a 16-bit value by do_CNbyte_count().  If that 32-bit value 
has the 0x8000 bit set, it will look like an error return code from 
do_CNbyte_count().

Roger Burrows