Change in vdsm[master]: stomp: Make sure the \0 is read before slicing the buffer

smizrahi at redhat.com smizrahi at redhat.com
Sun Jan 18 10:34:56 UTC 2015


Saggi Mizrahi has uploaded a new change for review.

Change subject: stomp: Make sure the \0 is read before slicing the buffer
......................................................................

stomp: Make sure the \0 is read before slicing the buffer

In python if you try and slice past the end of the list\string you get
an empty string and not an IndexError

The original code check that we got all the data and sliced past the
ending \0. But on rare cases where the message ended exactly with all
the content but the \0 was not received.

The slicing code would silently ignore the fact that the index doesn't
exist and would return an empty string and switch the parser state
making all future data have the wrong offset.

This in turn made the command '\0SEND' instead of 'SEND' which has no
handler and where silently ignored. The only way to solve this was to
reconnect.

Change-Id: Ib6d7d25719f814b97ebd2cc4c33ff25dc32e1357
Bug-Url: http://bugzilla.redhat.com/1181233
Signed-off-by: Saggi Mizrahi <smizrahi at redhat.com>
---
M lib/yajsonrpc/stomp.py
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/18/37018/1

diff --git a/lib/yajsonrpc/stomp.py b/lib/yajsonrpc/stomp.py
index 884bff6..8f78144 100644
--- a/lib/yajsonrpc/stomp.py
+++ b/lib/yajsonrpc/stomp.py
@@ -229,7 +229,7 @@
         buf = self._buffer
         cl = self._contentLength
         ndata = buf.tell()
-        if ndata < cl:
+        if ndata < (cl + 1):
             return False
 
         remainingBytes = 0


-- 
To view, visit http://gerrit.ovirt.org/37018
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib6d7d25719f814b97ebd2cc4c33ff25dc32e1357
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi at redhat.com>


More information about the vdsm-patches mailing list