mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
ftp: Do not base seq on number of pending commands
Previously, seq was computed as the result of |pending_commands|+1. This opened the possibility to override queued commands, as well as logging the same pending ftp reply multiple times. For example, when commands 1, 2, 3 are pending, command 1 may be dequeued, but the incoming command then receives seq 3 and overrides the already pending command 3. The second scenario happens when ftp_reply() selected command 3 as pending for logging, but is then followed by many ftp_request() events. This resulted in command 3's response being logged for every following ftp_request() over and over again. Avoid both scenarios by tracking the command sequence as an absolute counter.
This commit is contained in:
parent
a5b94f04fd
commit
ce4cbac1ef
4 changed files with 8 additions and 4 deletions
|
@ -165,7 +165,7 @@ function set_ftp_session(c: connection)
|
|||
Conn::register_removal_hook(c, finalize_ftp);
|
||||
|
||||
# Add a shim command so the server can respond with some init response.
|
||||
add_pending_cmd(c$ftp$pending_commands, "<init>", "");
|
||||
add_pending_cmd(c$ftp$pending_commands, ++c$ftp$command_seq, "<init>", "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ event ftp_request(c: connection, command: string, arg: string) &priority=5
|
|||
|
||||
# Queue up the new command and argument
|
||||
if ( |c$ftp$pending_commands| < max_pending_commands )
|
||||
add_pending_cmd(c$ftp$pending_commands, command, arg);
|
||||
add_pending_cmd(c$ftp$pending_commands, ++c$ftp$command_seq, command, arg);
|
||||
else
|
||||
Reporter::conn_weird("FTP_too_many_pending_commands", c,
|
||||
cat(|c$ftp$pending_commands|), "FTP");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue