melib/nntp: log error when command length exceeds 512 octets
Tests / Test on ${{ matrix.build }} (linux-amd64, ubuntu-latest, stable, x86_64-unknown-linux-gnu) (push) Failing after 8m11s Details

According to RFC 3977:

> Command lines MUST NOT exceed 512 octets, which includes the
> terminating CRLF pair

This commit adds a log::error entry when any sent command exceeds that
limit and recommends the user to report this as a bug.
fix/269-invalid-ctext-loop
Manos Pitsidianakis 2023-08-07 11:42:04 +03:00
parent c8abb15d78
commit b603524bc3
1 changed files with 15 additions and 1 deletions

View File

@ -482,11 +482,25 @@ impl NntpConnection {
}
pub async fn send_command(&mut self, command: &[u8]) -> Result<()> {
// RFC 3977
// 3. Basic Concepts
// 3.1.
// Commands and Responses Command lines MUST NOT exceed 512 octets, which
// includes the terminating CRLF pair.
if command.len() + b"\r\n".len() >= 512 {
log::error!(
"{}: Sending a command to the NNTP server that is over 511 bytes: this is invalid \
and should be fixed. Please report this as a bug to the melib bugtracker. The \
command line is `{:?}\\r\\n`",
&self.uid_store.account_name,
command
);
}
if let Err(err) =
try_await(async { self.stream.as_mut()?.send_command(command).await }).await
{
self.stream = Err(err.clone());
log::debug!("{:?}", err.kind);
log::debug!("NNTP send command error {:?} {}", err.kind, err);
if err.kind.is_network() {
self.connect().await?;
}