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

Bug#323716: apt uses wrong prototype for getsockopt



Package: apt
Version: 0.5.4

(also present in 0.6.40.1)

In methods/connect.cc, getsockopt() is used as:

  unsigned int Err;
  unsigned int Len = sizeof(Err);
  if (getsockopt(Fd,SOL_SOCKET,SO_ERROR,&Err,&Len) != 0)
     return _error->Errno("getsockopt",_("Failed"));

and similarly in methods/ftp.cc. That fifth parameter type is
functionally correct on some platforms, but is not the documented
prototype on many and is not even functionally equivalent on some. The
alternative standard apears to be:

  int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen);

I get compiler warnings on my darwin/ppc machines where socklen_t is
an int, or a size_t especially on 64-bit machines where size_t is
larger than an int. There is already a configure test for the presence
of a socklen_t type; can one assume that the fifth parameter to
getsockopt should always be socklen_t if that type exists?
Alternativelly, I've seen some programs do a configure test
specifically to determine the fifth argument of getsockopt. Any
thoughts on improving the platform portability here?

dan



Reply to: