Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit a14d17c

Browse files
committed
[Cleanup] Ensure port is within valid range
1 parent 3f982bf commit a14d17c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

engine/src/cmdse.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,13 @@ void MCAccept::exec_ctxt(MCExecContext &ctxt)
118118
uinteger_t t_port;
119119
if (!ctxt . EvalExprAsUInt(port, EE_ACCEPT_BADEXP, t_port))
120120
return;
121-
121+
122+
if (t_port > UINT16_MAX)
123+
{
124+
ctxt . LegacyThrow(EE_ACCEPT_BADEXP);
125+
return;
126+
}
127+
122128
MCNewAutoNameRef t_message;
123129
if (!ctxt . EvalExprAsNameRef(message, EE_ACCEPT_BADEXP, &t_message))
124130
return;

engine/src/socket_resolve.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,14 @@ bool MCS_name_to_sockaddr(MCStringRef p_name_in, struct sockaddr_in *r_addr, MCH
425425
}
426426
}
427427
else
428+
{
428429
port = MCNumberFetchAsInteger(*t_port_number);
430+
if (port > UINT16_MAX)
431+
{
432+
MCresult->sets("not a valid port");
433+
return false;
434+
}
435+
}
429436
}
430437
else
431438
t_name = MCValueRetain(*t_name_in);

0 commit comments

Comments
 (0)