meven added inline comments.

INLINE COMMENTS

> feverfew wrote in kio_sftp.cpp:1831-1832
> AFAICT the size of the buffer never changes so this will easily cause a 
> buffer overrun if I'm not mistaken?
> 
> Say for example you have a buffer with `buffer.size() == MAX_XFER_BUF_SIZE + 
> 1`. Then on the second iteration of the while loop (assuming `bytesWritten == 
> MAX_XFER_BUF_SIZE`) you'll do a `sftp_write()` pointing to a `char` buffer of 
> size 1, but which incorrectly states that the size is `MAX_XFER_BUF_SIZE`.

Maybe we can deduce the server buffer size based on the `bytesWritten` value : 
at init `serv_buffer_size =MAX_XFER_BUF_SIZE; ` and then ` if (length > 
bytesWritten) { serv_buffer_size = bytesWritten }` and use `serv_buffer_size` 
instead of MAX_XFER_BUF_SIZE in the loop.

REPOSITORY
  R320 KIO Extras

REVISION DETAIL
  https://phabricator.kde.org/D29634

To: sitter, ngraham, meven
Cc: meven, feverfew, kde-frameworks-devel, kfm-devel, waitquietly, azyx, 
nikolaik, pberestov, iasensio, aprcela, fprice, LeGast00n, cblack, 
fbampaloukas, alexde, Codezela, michaelh, spoorun, navarromorales, firef, 
ngraham, andrebarros, bruns, emmanuelp, rdieter, mikesomov

Reply via email to