-/* $Cambridge: exim/src/src/os.c,v 1.1 2004/10/07 10:39:01 ph10 Exp $ */
+/* $Cambridge: exim/src/src/os.c,v 1.6 2007/01/08 10:50:18 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2004 */
+/* Copyright (c) University of Cambridge 1995 - 2007 */
/* See the file NOTICE for conditions of use and distribution. */
#ifdef STAND_ALONE
if ((ifreq.V_ifr_flags & IFF_UP) == 0) continue;
/* On some operating systems we have to get the IP address of the interface
- by another call. On others, it's already there, but we must reinstate the
- data in ifreq, because SIOCGIFFLAGS may wreck it. */
+ by another call. On others, it's already there, but we must copy the full
+ length because we only copied the basic length above, and anyway,
+ GIFFLAGS may have wrecked the data. */
#ifndef SIOCGIFCONF_GIVES_ADDR
if (ioctl(vs, V_GIFADDR, (char *)&ifreq) < 0)
addrp = &ifreq.V_ifr_addr;
#else
- memcpy((char *)&ifreq, cp, sizeof(ifreq));
- memcpy(addrbuf, (char *)&(ifreq.V_ifr_addr), len - sizeof(ifreq.V_ifr_name));
+ memcpy(addrbuf, cp + offsetof(struct V_ifreq, V_ifr_addr),
+ len - sizeof(ifreq.V_ifr_name));
addrp = (struct sockaddr *)addrbuf;
#endif
/* Close the socket, and return the chain of data blocks. */
-close(vs);
+(void)close(vs);
return yield;
}