Sending a string should send a trainling zero as well.

This commit is contained in:
con
2009-07-28 17:40:15 +02:00
parent 5d2a5521e9
commit c430649768
3 changed files with 3 additions and 7 deletions

View File

@@ -1442,8 +1442,6 @@ void Adapter::startInferiorIfNeeded()
appendByte(&ba, 0); // ? appendByte(&ba, 0); // ?
QByteArray file("C:\\sys\\bin\\filebrowseapp.exe"); QByteArray file("C:\\sys\\bin\\filebrowseapp.exe");
file.append('\0');
file.append('\0');
appendString(&ba, file, TargetByteOrder); appendString(&ba, file, TargetByteOrder);
sendTrkMessage(0x40, CB(handleCreateProcess), ba); // Create Item sendTrkMessage(0x40, CB(handleCreateProcess), ba); // Create Item
} }

View File

@@ -629,10 +629,7 @@ void Adapter::startInferiorIfNeeded()
appendByte(&ba, 0); // ? appendByte(&ba, 0); // ?
appendByte(&ba, 0); // ? appendByte(&ba, 0); // ?
appendByte(&ba, 0); // ? appendByte(&ba, 0); // ?
QByteArray file = m_fileName.toLocal8Bit(); appendString(&ba, m_fileName.toLocal8Bit(), TargetByteOrder);
file.append('\0');
file.append('\0');
appendString(&ba, file, TargetByteOrder);
sendTrkMessage(TrkCreateItem, CB(handleCreateProcess), ba); // Create Item sendTrkMessage(TrkCreateItem, CB(handleCreateProcess), ba); // Create Item
} }

View File

@@ -264,9 +264,10 @@ void appendInt(QByteArray *ba, uint i, Endianness endian)
void appendString(QByteArray *ba, const QByteArray &str, Endianness endian) void appendString(QByteArray *ba, const QByteArray &str, Endianness endian)
{ {
const int n = str.size(); const int n = str.size();
appendShort(ba, n, endian); appendShort(ba, n+1, endian); // count the terminating \0
for (int i = 0; i != n; ++i) for (int i = 0; i != n; ++i)
ba->append(str.at(i)); ba->append(str.at(i));
ba->append('\0');
} }
QByteArray errorMessage(byte code) QByteArray errorMessage(byte code)