vfs: check userland buffers before reading them.
[haiku.git] / src / tests / kits / net / posixnet / GetAddrInfo.cpp
blob5ec2d709f951c86946bbfa51777ac1d9897360de
1 /*
2 * Copyright 2014, Haiku, inc.
3 * Distributed under the terms of the MIT licence
4 */
7 #include "GetAddrInfo.h"
9 #include <sys/types.h>
10 #include <sys/socket.h>
11 #include <netdb.h>
13 #include <cppunit/TestCaller.h>
14 #include <cppunit/TestSuite.h>
17 GetAddrInfoTest::GetAddrInfoTest()
22 GetAddrInfoTest::~GetAddrInfoTest()
27 void
28 GetAddrInfoTest::EmptyTest()
30 struct addrinfo* info;
31 addrinfo hint = {0};
32 hint.ai_family = AF_INET;
33 hint.ai_flags = AI_PASSIVE;
35 // Trying to resolve an empty host...
36 int result = getaddrinfo("", NULL, &hint, &info);
38 if (info)
39 freeaddrinfo(info);
41 // getaddrinfo shouldn't suggest that this may work better by trying again.
42 CPPUNIT_ASSERT(result != EAI_AGAIN);
46 /* static */ void
47 GetAddrInfoTest::AddTests(BTestSuite& parent)
49 CppUnit::TestSuite& suite = *new CppUnit::TestSuite("GetAddrInfoTest");
51 suite.addTest(new CppUnit::TestCaller<GetAddrInfoTest>(
52 "GetAddrInfoTest::EmptyTest", &GetAddrInfoTest::EmptyTest));
54 parent.addTest("GetAddrInfoTest", &suite);