Fix "skip to reply packet" method.
authorDavin McCall <davmac@davmac.org>
Sun, 10 Jan 2016 11:49:23 +0000 (11:49 +0000)
committerDavin McCall <davmac@davmac.org>
Sun, 10 Jan 2016 11:49:23 +0000 (11:49 +0000)
It was possible to skip over an information packet but not read any
further reply, so the packet type test (rbuffer[0] == ...) would not
work correctly.

src/dinitctl.cc

index 7399cb559fd7fb70624dba64b0791cf63c6987fe..11db04c55c88dc979948b7a4f3a48e85da59c52d 100644 (file)
@@ -60,8 +60,10 @@ static void wait_for_reply(CPBuffer &rbuffer, int fd)
         // Information packet; discard.
         fillBufferTo(&rbuffer, fd, 1);
         int pktlen = (unsigned char) rbuffer[1];
+        
+        rbuffer.consume(1);  // Consume one byte so we'll read one byte of the next packet
         fillBufferTo(&rbuffer, fd, pktlen);
-        rbuffer.consume(pktlen);
+        rbuffer.consume(pktlen - 1);
     }
 }