Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/SoftEtherVPN/SoftEtherVPN_Stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaiyuu Nobori <da.git@softether.co.jp>2016-11-27 11:23:43 +0300
committerGitHub <noreply@github.com>2016-11-27 11:23:43 +0300
commit3292d83a623014bbb67439153e88e7296f9e6913 (patch)
treedc10edec37d07cb0abc89f8f11f064ea70b2bd83
parent1e17c9bcfd7e7b31756aa5389bcbff76c2c9c88a (diff)
parent9bc67cc293cfcb130fa02543960a909c21391a92 (diff)
Merge pull request #248 from ajeecai/master
Fix that ParseTcpOption doesn't work correctly
-rw-r--r--src/Cedar/Virtual.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/Cedar/Virtual.c b/src/Cedar/Virtual.c
index 2ce41b02..e2d06723 100644
--- a/src/Cedar/Virtual.c
+++ b/src/Cedar/Virtual.c
@@ -5429,7 +5429,7 @@ SCAN_FIRST:
void ParseTcpOption(TCP_OPTION *o, void *data, UINT size)
{
UCHAR *buf = (UCHAR *)data;
- UINT i;
+ UINT i = 0;
UINT value_size = 0;
UINT value_id = 0;
UCHAR value[128];
@@ -5441,13 +5441,18 @@ void ParseTcpOption(TCP_OPTION *o, void *data, UINT size)
Zero(o, sizeof(TCP_OPTION));
- for (i = 0;i < size;i++)
+ while(i < size)
{
if (buf[i] == 0)
{
return;
}
- if (buf[i] != 1)
+ else if (buf[i] == 1)
+ {
+ i++;
+ continue;
+ }
+ else
{
value_id = buf[i];
i++;
@@ -5466,12 +5471,14 @@ void ParseTcpOption(TCP_OPTION *o, void *data, UINT size)
return;
}
value_size -= 2;
+
Copy(value, &buf[i], value_size);
i += value_size;
- if (i >= size)
+ if (i > size)
{
return;
}
+
switch (value_id)
{
case 2: // MSS
@@ -5486,14 +5493,13 @@ void ParseTcpOption(TCP_OPTION *o, void *data, UINT size)
if (value_size == 1)
{
UCHAR *wss = (UCHAR *)value;
- o->WindowScaling = Endian16(*wss);
+ o->WindowScaling = *wss;
}
break;
}
}
}
-
}
// Create a new NAT TCP session