Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
17713f39
Commit
17713f39
authored
Nov 09, 2015
by
Marcin Siodelski
Browse files
[4106] Throw exception from IPC for out of range port.
parent
7c43a3eb
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp4/dhcp4_dhcp4o6_ipc.cc
View file @
17713f39
...
...
@@ -37,9 +37,6 @@ void Dhcp4o6Ipc::open() {
Dhcp4o6IpcBase
::
close
();
return
;
}
if
(
port
>
65534
)
{
isc_throw
(
OutOfRange
,
"DHCP4o6 port "
<<
port
);
}
int
old_fd
=
socket_fd_
;
socket_fd_
=
Dhcp4o6IpcBase
::
open
(
static_cast
<
uint16_t
>
(
port
),
ENDPOINT_TYPE_V4
);
...
...
src/bin/dhcp6/dhcp6_dhcp4o6_ipc.cc
View file @
17713f39
...
...
@@ -37,9 +37,6 @@ void Dhcp4o6Ipc::open() {
Dhcp4o6IpcBase
::
close
();
return
;
}
if
(
port
>
65534
)
{
isc_throw
(
OutOfRange
,
"DHCP4o6 port "
<<
port
);
}
int
old_fd
=
socket_fd_
;
socket_fd_
=
Dhcp4o6IpcBase
::
open
(
static_cast
<
uint16_t
>
(
port
),
ENDPOINT_TYPE_V6
);
...
...
src/lib/dhcpsrv/dhcp4o6_ipc.cc
View file @
17713f39
...
...
@@ -40,6 +40,12 @@ Dhcp4o6IpcBase::~Dhcp4o6IpcBase() {
}
int
Dhcp4o6IpcBase
::
open
(
const
uint16_t
port
,
const
EndpointType
&
endpoint_type
)
{
// Check if the port value is correct.
if
(
port
>
65534
)
{
isc_throw
(
Dhcp4o6IpcError
,
"specified port "
<<
port
<<
" is out of"
" range. The port value must not be greater than 65534 "
);
}
if
(
port
==
port_
)
{
// No change: nothing to do
return
(
socket_fd_
);
...
...
src/lib/dhcpsrv/tests/dhcp4o6_ipc_unittest.cc
View file @
17713f39
...
...
@@ -531,6 +531,19 @@ TEST_F(Dhcp4o6IpcBaseTest, openError) {
EXPECT_EQ
(
TEST_PORT
+
10
,
ipc
.
getPort
());
}
// This test verifies that the IPC returns an error when trying to bind
// to the out of range port.
TEST_F
(
Dhcp4o6IpcBaseTest
,
invalidPortError4
)
{
TestIpc
ipc
(
65535
,
TestIpc
::
ENDPOINT_TYPE_V4
);
EXPECT_THROW
(
ipc
.
open
(),
Dhcp4o6IpcError
);
}
// This test verifies that the IPC returns an error when trying to bind
// to the out of range port.
TEST_F
(
Dhcp4o6IpcBaseTest
,
invalidPortError6
)
{
TestIpc
ipc
(
65535
,
TestIpc
::
ENDPOINT_TYPE_V6
);
EXPECT_THROW
(
ipc
.
open
(),
Dhcp4o6IpcError
);
}
// This test verifies that receiving packet over the IPC fails when there
// is no vendor option present.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment