Skip to content

Commit 53cd6e8

Browse files
jubeormk1Copilot
andcommitted
Addressing potential integer overflow
Thanks to @mkj for spotting and proposing a fix Co-authored-by: Copilot <copilot@github.com>
1 parent 611d792 commit 53cd6e8

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

sftp/src/sftpsource.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ pub struct SftpSource<'de> {
2020

2121
impl<'de> SSHSource<'de> for SftpSource<'de> {
2222
fn take(&mut self, len: usize) -> sunset::sshwire::WireResult<&'de [u8]> {
23-
if len + self.index > self.buffer.len() {
23+
if len.checked_add(self.index).ok_or(WireError::RanOut)? > self.buffer.len()
24+
{
2425
return Err(WireError::RanOut);
2526
}
2627
let original_index = self.index;

0 commit comments

Comments
 (0)