From d27e1481571a0e2f5c7cbd5ae7c02377694dad44 Mon Sep 17 00:00:00 2001 From: sorz Date: Mon, 21 Nov 2016 05:33:30 +0000 Subject: [PATCH] Fix lost of escape on frames --- sstpd/codecmodule.c | 8 +++++--- sstpd/ppp.py | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sstpd/codecmodule.c b/sstpd/codecmodule.c index 4be5a7a..50bf6ff 100644 --- a/sstpd/codecmodule.c +++ b/sstpd/codecmodule.c @@ -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) @@ -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; } diff --git a/sstpd/ppp.py b/sstpd/ppp.py index 593073e..f7358f4 100644 --- a/sstpd/ppp.py +++ b/sstpd/ppp.py @@ -14,6 +14,7 @@ class PPPDProtocol(ProcessProtocol): def __init__(self): self.frameBuffer = b'' + self.frameEscaped = False self.paused = False @@ -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)