Bug#325010: fileutl.cc error handling necessarily broken
Package: apt
Version: 0.6.40.1
In fileutl.cc, we see this:
unsigned long FileFd::Size()
{
struct stat Buf;
if (fstat(iFd,&Buf) != 0)
return _error->Errno("fstat","Unable to determine the file size");
return Buf.st_size;
}
This is wrong, because _error->Errno is supposed to be used like that
in functions which return a boolean success code, not in functions
which return a value. The interface to ::Size does not permit any
error returns and is therefore wrong: it should return boolean like
most of the other functions, and return the size through a reference
argument (like, say, FTPConn::Size).
I don't supply a patch because (a) it would be large and quickly
outdated (b) it's an easy job to fix the declaration of ::Size and
then have the compiler find all of the callers.
Thanks,
Ian.
Reply to: