Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit f228ea0

Browse files
Merge pull request #26 from stephen-palmer/master
bugfix/bogus-quit-detected
2 parents 731d478 + 6fa8310 commit f228ea0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/server/client_stream_processor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class ClientStreamProcessor extends Transform {
122122
if(!fillBufferWithData()) {
123123

124124
// Quit?
125-
if (data[data.length - 1] === CMD_QUIT) {
125+
if (!readState.didParseCmd && data[data.length - 1] === CMD_QUIT) {
126126
this.push('q');
127127
}
128128

test/protocol.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ describe("Protocol", () => {
153153

154154
tests.forEach(function (test) {
155155
it(`should store ${test.ext} data with a (${test.cmd}) command (client write packet size = ${test.packetSize})`, () => {
156+
// Insert 'q' character ('Quit' command) into the GUID, to catch subtle protocol errors when packet size is 1
157+
if(test.packetSize === 1) {
158+
test.data.guid[0] = test.data.guid[test.data.guid.length - 1] = 'q'.charCodeAt(0);
159+
}
160+
156161
const buf = Buffer.from(
157162
encodeCommand(cmd.transactionStart, test.data.guid, test.data.hash) +
158163
encodeCommand(test.cmd, null, null, test.data[test.ext]) +

0 commit comments

Comments
 (0)