Hi there,
 
I found a bug in the perl script module of Irssi. When you have a dcc get for a 
file which is larger than 2GB, the /dcc command shows correct file size and 
ETA, due to the usage of type uoff_t for the filesize in dcc-file-rec.h. This 
is correct. The type uoff_t is a u_int64_t (unsigned long long).
However when accessing the dcc-array in a perl script within irssi by using the 
function Irssi::Irc::dccs() a dcc entry for a file with size bigger than 2GB 
contains not the correct file size but a negative value. Cause of the problem 
is the convertion from uoff_t to the hash value in file src/perl/irc/Irc.xs 
line 69:
 
hv_store(hv, "size", 4, newSViv(dcc->size), 0);
 
This takes only the first 32 bits as signed integer which results in negative 
values for bit 31 set to 1. To solve this problem, you could use newSVuv 
instead of newSViv:
 
hv_store(hv, "size", 4, newSVuv(dcc->size), 0);
 
This however solves the problem only for files smaller than 4GB. The best 
solution is to store the file size as a string in the hash:
 
char* size_str;
//...
size_str = dcc_get_size_str(dcc->size); 
hv_store(hv, "size", 4, newSVpv(size_str), 0);
g_free(size_str);
 
The same is true for the transfd value (line 53 in file Irc.xs):
 
 hv_store(hv, "transfd", 7, newSViv(dcc->transfd), 0);

should be replaced with:
 
char* transfd_str;
//...
transfd_str = dcc_get_size_str(dcc->transfd); 
hv_store(hv, "transfd", 4, newSVpv(transfd_str), 0);
g_free(transfd_str);
 
It would be great if you can integrate this or another appropriate solution 
into the next release of irssi. Please let me know whether my info was useful.
 
Thank you,
Kai Lehmann

Kai Lehmann
Papendorf Software Engineering GmbH

Tel Calw: +49 (0)7051 93698 - 0   
Fax Calw: +49 (0)7051 93698 - 22  
Mobile  : +49 (0)174 32 41 945

Reply via email to