mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-08-08 09:21:48 +08:00
main: bound-check sec-mod message length before allocation
handle_sec_mod_commands() lacked an upper-bound check on the `length` field received from the sec-mod socket before passing it to talloc_size(). The worker command handler already applies a MAX_MSG_SIZE guard. Replace the redundant (int)length < 0 cast (impossible for uint32_t) with a length > MAX_MSG_SIZE check, matching the pattern in handle_worker_commands(). Also fix the format specifier from %d to %u for the uint32_t length. Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
This commit is contained in:
@@ -111,10 +111,10 @@ int handle_sec_mod_commands(sec_mod_instance_st *sec_mod_instance)
|
||||
}
|
||||
|
||||
if (ret < 5 || cmd <= MIN_SECM_CMD || cmd >= MAX_SECM_CMD ||
|
||||
(int)length < 0) {
|
||||
length > MAX_MSG_SIZE) {
|
||||
mslog(s, NULL, LOG_ERR,
|
||||
"main received invalid message from sec-mod of %d bytes (cmd: %u)\n",
|
||||
(int)length, (unsigned int)cmd);
|
||||
"main received invalid message from sec-mod of %u bytes (cmd: %u)\n",
|
||||
(unsigned int)length, (unsigned int)cmd);
|
||||
return ERR_BAD_COMMAND;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user