Commit 85ee97b1 authored by Kurt Hindenburg's avatar Kurt Hindenburg

For zmodem transfers, do not read entire file into memory

Read at most 1Mb of data instead of loading entire file into memory.
Add -e to force sender to escape all control characters

Patch/Bug by gonglinglei gmail com

BUG: 389906
FIXED-IN: 18.04
parent 2dd5ac7f
......@@ -62,6 +62,8 @@ using namespace Konsole;
int Session::lastSessionId = 0;
static bool show_disallow_certain_dbus_methods_message = true;
static const int ZMODEM_BUFFER_SIZE = 1048576; // 1 Mb
Session::Session(QObject* parent) :
QObject(parent)
, _shellProcess(nullptr)
......@@ -1281,7 +1283,7 @@ void Session::startZModem(const QString& zmodem, const QString& dir, const QStri
_zmodemProc = new KProcess();
_zmodemProc->setOutputChannelMode(KProcess::SeparateChannels);
*_zmodemProc << zmodem << QStringLiteral("-v") << list;
*_zmodemProc << zmodem << QStringLiteral("-v") << QStringLiteral("-e") << list;
if (!dir.isEmpty()) {
_zmodemProc->setWorkingDirectory(dir);
......@@ -1308,13 +1310,12 @@ void Session::startZModem(const QString& zmodem, const QString& dir, const QStri
void Session::zmodemReadAndSendBlock()
{
_zmodemProc->setReadChannel(QProcess::StandardOutput);
QByteArray data = _zmodemProc->readAll();
QByteArray data = _zmodemProc->read(ZMODEM_BUFFER_SIZE);
if (data.count() == 0) {
return;
while (data.count() != 0) {
_shellProcess->sendData(data);
data = _zmodemProc->read(ZMODEM_BUFFER_SIZE);
}
_shellProcess->sendData(data);
}
void Session::zmodemReadStatus()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment