Skip to content

Commit

Permalink
Fix lost of escape on frames
Browse files Browse the repository at this point in the history
  • Loading branch information
sorz committed Nov 21, 2016
1 parent 9db86b6 commit d27e148
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions sstpd/codecmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,16 @@ codec_unescape(PyObject *self, PyObject *args)
const char* ldata; /* last unused unescaped data */
int data_len;
int ldata_len;
PyObject* py_escaped;
char* buffer; /* frame buffer */
int pos; /* length of frame */
PyObject* frames;
bool escaped = false;
bool escaped;
int i;

if (!PyArg_ParseTuple(args, "s#s#", &data, &data_len, &ldata, &ldata_len))
if (!PyArg_ParseTuple(args, "s#s#O", &data, &data_len, &ldata, &ldata_len, &py_escaped))
return NULL;
escaped = PyObject_IsTrue(py_escaped);

buffer = malloc(sizeof(char[data_len + ldata_len]));
if (!buffer)
Expand Down Expand Up @@ -155,7 +157,7 @@ codec_unescape(PyObject *self, PyObject *args)
}
}

PyObject* result = Py_BuildValue("Ns#", frames, buffer, pos);
PyObject* result = Py_BuildValue("Ns#O", frames, buffer, pos, escaped ? Py_True : Py_False);
free(buffer);
return result;
}
Expand Down
4 changes: 3 additions & 1 deletion sstpd/ppp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class PPPDProtocol(ProcessProtocol):

def __init__(self):
self.frameBuffer = b''
self.frameEscaped = False
self.paused = False


Expand All @@ -24,7 +25,8 @@ def writeFrame(self, frame):
def outReceived(self, data):
if __debug__:
logging.log(VERBOSE, "Raw data: %s", hexdump(data))
frames, self.frameBuffer = unescape(data, self.frameBuffer)
frames, self.frameBuffer, self.frameEscaped = \
unescape(data, self.frameBuffer, self.frameEscaped)
for frame in frames:
self.pppFrameReceived(frame)

Expand Down

0 comments on commit d27e148

Please sign in to comment.