Author: axeld Date: 2010-12-01 18:32:27 +0100 (Wed, 01 Dec 2010) New Revision: 39693 Changeset: http://dev.haiku-os.org/changeset/39693 Modified: haiku/trunk/src/kits/network/libnetapi/NetworkAddress.cpp Log: * The constructors weren't defined in declaration order. * Unflatten() will now check whether the size of the buffer was large enough to hold a valid address. Modified: haiku/trunk/src/kits/network/libnetapi/NetworkAddress.cpp =================================================================== --- haiku/trunk/src/kits/network/libnetapi/NetworkAddress.cpp 2010-12-01 14:35:51 UTC (rev 39692) +++ haiku/trunk/src/kits/network/libnetapi/NetworkAddress.cpp 2010-12-01 17:32:27 UTC (rev 39693) @@ -16,6 +16,12 @@ #include <sys/sockio.h> +BNetworkAddress::BNetworkAddress() +{ + Unset(); +} + + BNetworkAddress::BNetworkAddress(const char* host, uint16 port, uint32 flags) { SetTo(host, port, flags); @@ -93,12 +99,6 @@ } -BNetworkAddress::BNetworkAddress() -{ - Unset(); -} - - BNetworkAddress::~BNetworkAddress() { } @@ -995,6 +995,11 @@ return fStatus = B_BAD_TYPE; memcpy(&fAddress, buffer, min_c(size, (ssize_t)sizeof(fAddress))); + + // check if this can contain a valid address + if (fAddress.ss_family != AF_UNSPEC && size < (ssize_t)sizeof(sockaddr)) + return fStatus = B_BAD_VALUE; + return fStatus = B_OK; }