Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Eclipse Foundation
Eclipse Mosquitto
提交
a3c680fb
E
Eclipse Mosquitto
项目概览
镜像
/
Eclipse Foundation
/
Eclipse Mosquitto
9 个月 前同步成功
通知
36
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
Eclipse Mosquitto
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a3c680fb
编写于
6月 09, 2023
作者:
R
Roger A. Light
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix for Eclipse #581199
上级
411ed41c
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
81 addition
and
1 deletion
+81
-1
lib/packet_mosq.c
lib/packet_mosq.c
+1
-1
test/broker/01-bad-initial-packets.py
test/broker/01-bad-initial-packets.py
+78
-0
test/broker/Makefile
test/broker/Makefile
+1
-0
test/broker/test.py
test/broker/test.py
+1
-0
未找到文件。
lib/packet_mosq.c
浏览文件 @
a3c680fb
...
...
@@ -378,7 +378,7 @@ int packet__read(struct mosquitto *mosq)
#ifdef WITH_BROKER
G_BYTES_RECEIVED_INC
(
1
);
/* Clients must send CONNECT as their first command. */
if
(
!
(
mosq
->
bridge
)
&&
state
==
mosq_cs_
connected
&&
(
byte
&
0xF0
)
!=
CMD_CONNECT
){
if
(
!
(
mosq
->
bridge
)
&&
state
==
mosq_cs_
new
&&
(
byte
&
0xF0
)
!=
CMD_CONNECT
){
return
MOSQ_ERR_PROTOCOL
;
}
#endif
...
...
test/broker/01-bad-initial-packets.py
0 → 100755
浏览文件 @
a3c680fb
#!/usr/bin/env python3
# Test whether non-CONNECT packets as an initial packet can cause excess memory use
from
mosq_test_helper
import
*
import
psutil
def
write_config
(
filename
,
port
):
with
open
(
filename
,
'w'
)
as
f
:
f
.
write
(
f
"listener
{
port
}
\n
"
)
f
.
write
(
"allow_anonymous true
\n
"
)
f
.
write
(
"sys_interval 1
\n
"
)
def
do_send
(
port
,
socks
,
payload
):
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
socks
.
append
(
sock
)
sock
.
connect
((
"127.0.0.1"
,
port
))
try
:
sock
.
send
(
payload
)
except
ConnectionResetError
:
pass
def
do_test
(
port
):
rc
=
1
conf_file
=
os
.
path
.
basename
(
__file__
).
replace
(
'.py'
,
'.conf'
)
write_config
(
conf_file
,
port
)
broker
=
mosq_test
.
start_broker
(
filename
=
os
.
path
.
basename
(
__file__
),
port
=
port
,
use_conf
=
True
)
try
:
socks
=
[]
do_send
(
port
,
socks
,
b
"
\x20\x80\x80\x80
t"
+
b
"
\01
"
*
100000000
)
# CONNACK
do_send
(
port
,
socks
,
b
"
\x30\x80\x80\x80
t"
+
b
"
\01
"
*
100000000
)
# PUBLISH
do_send
(
port
,
socks
,
b
"
\x40\x80\x80\x80
t"
+
b
"
\01
"
*
100000000
)
# PUBACK
do_send
(
port
,
socks
,
b
"
\x50\x80\x80\x80
t"
+
b
"
\01
"
*
100000000
)
# PUBREC
do_send
(
port
,
socks
,
b
"
\x60\x80\x80\x80
t"
+
b
"
\01
"
*
100000000
)
# PUBREL
do_send
(
port
,
socks
,
b
"
\x70\x80\x80\x80
t"
+
b
"
\01
"
*
100000000
)
# PUBCOMP
do_send
(
port
,
socks
,
b
"
\x80\x80\x80\x80
t"
+
b
"
\01
"
*
100000000
)
# SUBSCRIBE
do_send
(
port
,
socks
,
b
"
\x90\x80\x80\x80
t"
+
b
"
\01
"
*
100000000
)
# SUBACK
do_send
(
port
,
socks
,
b
"
\xA0\x80\x80\x80
t"
+
b
"
\01
"
*
100000000
)
# UNSUBSCRIBE
do_send
(
port
,
socks
,
b
"
\xB0\x80\x80\x80
t"
+
b
"
\01
"
*
100000000
)
# UNSUBACK
do_send
(
port
,
socks
,
b
"
\xC0\x80\x80\x80
t"
+
b
"
\01
"
*
100000000
)
# PINGREQ
do_send
(
port
,
socks
,
b
"
\xD0\x80\x80\x80
t"
+
b
"
\01
"
*
100000000
)
# PINGRESP
do_send
(
port
,
socks
,
b
"
\xE0\x80\x80\x80
t"
+
b
"
\01
"
*
100000000
)
# DISCONNECT
do_send
(
port
,
socks
,
b
"
\xF0\x80\x80\x80
t"
+
b
"
\01
"
*
100000000
)
# AUTH
mem
=
psutil
.
Process
(
broker
.
pid
).
memory_info
().
vms
for
s
in
socks
:
s
.
close
()
limit
=
25000000
if
mem
>
limit
:
raise
mosq_test
.
TestError
(
f
"Process memory
{
mem
}
greater than limit of
{
limit
}
"
)
rc
=
0
except
MemoryError
:
print
(
"Memory error!"
)
except
Exception
as
e
:
print
(
e
)
except
mosq_test
.
TestError
:
pass
finally
:
os
.
remove
(
conf_file
)
broker
.
terminate
()
broker
.
wait
()
(
stdo
,
stde
)
=
broker
.
communicate
()
if
rc
:
print
(
stde
.
decode
(
'utf-8'
))
exit
(
rc
)
port
=
mosq_test
.
get_port
()
do_test
(
port
)
exit
(
0
)
test/broker/Makefile
浏览文件 @
a3c680fb
...
...
@@ -23,6 +23,7 @@ msg_sequence_test:
./msg_sequence_test.py
01
:
./01-bad-initial-packets.py
./01-connect-575314.py
./01-connect-allow-anonymous.py
./01-connect-disconnect-v5.py
...
...
test/broker/test.py
浏览文件 @
a3c680fb
...
...
@@ -5,6 +5,7 @@ import ptest
tests
=
[
#(ports required, 'path'),
(
1
,
'./01-bad-initial-packets.py'
),
(
1
,
'./01-connect-575314.py'
),
(
1
,
'./01-connect-allow-anonymous.py'
),
(
1
,
'./01-connect-disconnect-v5.py'
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录