Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Eclipse Foundation
Eclipse Paho C Client Library for the MQTT Protocol
比较版本
3933f8b796523576c8e42abf80ca6ce650f9b7dc...08132d4cd76883b6e7c4a3d31891e7fa43171fbc
E
Eclipse Paho C Client Library for the MQTT Protocol
项目概览
镜像
/
Eclipse Foundation
/
Eclipse Paho C Client Library for the MQTT Protocol
9 个月 前同步成功
通知
251
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
Eclipse Paho C Client Library for the MQTT Protocol
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
源分支
08132d4cd76883b6e7c4a3d31891e7fa43171fbc
选择Git版本
...
目标分支
3933f8b796523576c8e42abf80ca6ce650f9b7dc
选择Git版本
比较
Commits (3)
https://gitcode.net/awesome-mirrors/eclipse/paho.mqtt.c/-/commit/fd213a8461946dded03033ba9e4e99e046af6967
Handle 0 length arrays properly #1356
2023-05-15T15:55:18+01:00
Ian Craggs
icraggs@gmail.com
https://gitcode.net/awesome-mirrors/eclipse/paho.mqtt.c/-/commit/357c392db101042e9253b39e640308eff9741c0d
Check cause connectionLost parameter in samples
2023-05-17T12:46:44+01:00
Ian Craggs
icraggs@gmail.com
https://gitcode.net/awesome-mirrors/eclipse/paho.mqtt.c/-/commit/08132d4cd76883b6e7c4a3d31891e7fa43171fbc
Correct some memory accesses
2023-05-17T17:59:10+01:00
Ian Craggs
icraggs@gmail.com
隐藏空白更改
内联
并排
Showing
9 changed file
with
66 addition
and
39 deletion
+66
-39
src/MQTTAsyncUtils.c
src/MQTTAsyncUtils.c
+6
-6
src/Socket.c
src/Socket.c
+28
-5
src/samples/MQTTAsync_publish.c
src/samples/MQTTAsync_publish.c
+3
-2
src/samples/MQTTAsync_publish_time.c
src/samples/MQTTAsync_publish_time.c
+3
-2
src/samples/MQTTClient_publish_async.c
src/samples/MQTTClient_publish_async.c
+3
-2
src/samples/MQTTClient_subscribe.c
src/samples/MQTTClient_subscribe.c
+3
-2
test/test1.c
test/test1.c
+2
-2
test/test9.c
test/test9.c
+10
-10
test/test95.c
test/test95.c
+8
-8
未找到文件。
src/MQTTAsyncUtils.c
浏览文件 @
08132d4c
...
...
@@ -3034,9 +3034,9 @@ static MQTTPacket* MQTTAsync_cycle(SOCKET* sock, unsigned long timeout, int* rc)
pack
->
header
.
bits
.
type
==
PUBREC
)
{
int
msgid
=
0
,
msgtype
=
0
,
ackrc
=
0
,
mqttversion
=
0
;
unsigned
int
msgtype
=
0
,
ackrc
=
0
;
MQTTProperties
msgprops
=
MQTTProperties_initializer
;
Publications
*
pubToRemove
=
NULL
;
...
...
@@ -3055,11 +3055,11 @@ static MQTTPacket* MQTTAsync_cycle(SOCKET* sock, unsigned long timeout, int* rc)
}
}
if
(
pack
->
header
.
bits
.
type
==
PUBCOMP
)
if
(
msg
type
==
PUBCOMP
)
*
rc
=
MQTTProtocol_handlePubcomps
(
pack
,
*
sock
,
&
pubToRemove
);
else
if
(
pack
->
header
.
bits
.
type
==
PUBREC
)
else
if
(
msg
type
==
PUBREC
)
*
rc
=
MQTTProtocol_handlePubrecs
(
pack
,
*
sock
,
&
pubToRemove
);
else
if
(
pack
->
header
.
bits
.
type
==
PUBACK
)
else
if
(
msg
type
==
PUBACK
)
*
rc
=
MQTTProtocol_handlePubacks
(
pack
,
*
sock
,
&
pubToRemove
);
if
(
!
m
)
Log
(
LOG_ERROR
,
-
1
,
"PUBCOMP, PUBACK or PUBREC received for no client, msgid %d"
,
msgid
);
...
...
@@ -3114,7 +3114,7 @@ static MQTTPacket* MQTTAsync_cycle(SOCKET* sock, unsigned long timeout, int* rc)
data
.
token
=
command
->
command
.
token
;
data
.
reasonCode
=
ackrc
;
data
.
properties
=
msgprops
;
data
.
packet_type
=
pack
->
header
.
bits
.
type
;
data
.
packet_type
=
msg
type
;
Log
(
TRACE_MIN
,
-
1
,
"Calling publish failure for client %s"
,
m
->
c
->
clientID
);
(
*
(
command
->
command
.
onFailure5
))(
command
->
command
.
context
,
&
data
);
}
...
...
src/Socket.c
浏览文件 @
08132d4c
/*******************************************************************************
* Copyright (c) 2009, 202
2
IBM Corp., Ian Craggs and others
* Copyright (c) 2009, 202
3
IBM Corp., Ian Craggs and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
...
...
@@ -516,17 +516,40 @@ SOCKET Socket_getReadySocket(int more_work, int timeout, mutex_type mutex, int*
if
(
mod_s
.
nfds
!=
mod_s
.
saved
.
nfds
)
{
mod_s
.
saved
.
nfds
=
mod_s
.
nfds
;
if
(
mod_s
.
saved
.
fds_read
)
if
(
mod_s
.
nfds
==
0
)
{
if
(
mod_s
.
saved
.
fds_read
)
{
free
(
mod_s
.
saved
.
fds_read
);
mod_s
.
saved
.
fds_read
=
NULL
;
}
}
else
if
(
mod_s
.
saved
.
fds_read
)
mod_s
.
saved
.
fds_read
=
realloc
(
mod_s
.
saved
.
fds_read
,
mod_s
.
nfds
*
sizeof
(
struct
pollfd
));
else
mod_s
.
saved
.
fds_read
=
malloc
(
mod_s
.
nfds
*
sizeof
(
struct
pollfd
));
if
(
mod_s
.
saved
.
fds_write
)
if
(
mod_s
.
nfds
==
0
)
{
if
(
mod_s
.
saved
.
fds_write
)
{
free
(
mod_s
.
saved
.
fds_write
);
mod_s
.
saved
.
fds_write
=
NULL
;
}
}
else
if
(
mod_s
.
saved
.
fds_write
)
mod_s
.
saved
.
fds_write
=
realloc
(
mod_s
.
saved
.
fds_write
,
mod_s
.
nfds
*
sizeof
(
struct
pollfd
));
else
mod_s
.
saved
.
fds_write
=
malloc
(
mod_s
.
nfds
*
sizeof
(
struct
pollfd
));
}
memcpy
(
mod_s
.
saved
.
fds_read
,
mod_s
.
fds_read
,
mod_s
.
nfds
*
sizeof
(
struct
pollfd
));
memcpy
(
mod_s
.
saved
.
fds_write
,
mod_s
.
fds_write
,
mod_s
.
nfds
*
sizeof
(
struct
pollfd
));
if
(
mod_s
.
fds_read
==
NULL
)
mod_s
.
saved
.
fds_read
=
NULL
;
else
memcpy
(
mod_s
.
saved
.
fds_read
,
mod_s
.
fds_read
,
mod_s
.
nfds
*
sizeof
(
struct
pollfd
));
if
(
mod_s
.
fds_write
==
NULL
)
mod_s
.
saved
.
fds_write
=
NULL
;
else
memcpy
(
mod_s
.
saved
.
fds_write
,
mod_s
.
fds_write
,
mod_s
.
nfds
*
sizeof
(
struct
pollfd
));
if
(
mod_s
.
saved
.
nfds
==
0
)
{
...
...
src/samples/MQTTAsync_publish.c
浏览文件 @
08132d4c
/*******************************************************************************
* Copyright (c) 2012, 202
2
IBM Corp., Ian Craggs
* Copyright (c) 2012, 202
3
IBM Corp., Ian Craggs
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
...
...
@@ -45,7 +45,8 @@ void connlost(void *context, char *cause)
int
rc
;
printf
(
"
\n
Connection lost
\n
"
);
printf
(
" cause: %s
\n
"
,
cause
);
if
(
cause
)
printf
(
" cause: %s
\n
"
,
cause
);
printf
(
"Reconnecting
\n
"
);
conn_opts
.
keepAliveInterval
=
20
;
...
...
src/samples/MQTTAsync_publish_time.c
浏览文件 @
08132d4c
/*******************************************************************************
* Copyright (c) 2012, 202
0
IBM Corp.
* Copyright (c) 2012, 202
3
IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
...
...
@@ -62,7 +62,8 @@ void connlost(void *context, char *cause)
int
rc
;
printf
(
"
\n
Connection lost
\n
"
);
printf
(
" cause: %s
\n
"
,
cause
);
if
(
cause
)
printf
(
" cause: %s
\n
"
,
cause
);
printf
(
"Reconnecting
\n
"
);
conn_opts
.
keepAliveInterval
=
20
;
...
...
src/samples/MQTTClient_publish_async.c
浏览文件 @
08132d4c
/*******************************************************************************
* Copyright (c) 2012, 202
2
IBM Corp., Ian Craggs
* Copyright (c) 2012, 202
3
IBM Corp., Ian Craggs
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
...
...
@@ -53,7 +53,8 @@ int msgarrvd(void *context, char *topicName, int topicLen, MQTTClient_message *m
void
connlost
(
void
*
context
,
char
*
cause
)
{
printf
(
"
\n
Connection lost
\n
"
);
printf
(
" cause: %s
\n
"
,
cause
);
if
(
cause
)
printf
(
" cause: %s
\n
"
,
cause
);
}
int
main
(
int
argc
,
char
*
argv
[])
...
...
src/samples/MQTTClient_subscribe.c
浏览文件 @
08132d4c
/*******************************************************************************
* Copyright (c) 2012, 202
2
IBM Corp., Ian Craggs
* Copyright (c) 2012, 202
3
IBM Corp., Ian Craggs
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
...
...
@@ -47,7 +47,8 @@ int msgarrvd(void *context, char *topicName, int topicLen, MQTTClient_message *m
void
connlost
(
void
*
context
,
char
*
cause
)
{
printf
(
"
\n
Connection lost
\n
"
);
printf
(
" cause: %s
\n
"
,
cause
);
if
(
cause
)
printf
(
" cause: %s
\n
"
,
cause
);
}
int
main
(
int
argc
,
char
*
argv
[])
...
...
test/test1.c
浏览文件 @
08132d4c
/*******************************************************************************
* Copyright (c) 2009, 202
2
IBM Corp., Ian Craggs
* Copyright (c) 2009, 202
3
IBM Corp., Ian Craggs
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
...
...
@@ -750,9 +750,9 @@ int test4_run(int qos)
while
(
tokens
[
i
]
!=
-
1
)
MyLog
(
LOGA_DEBUG
,
"Pending delivery token %d"
,
tokens
[
i
++
]);
MQTTClient_free
(
tokens
);
assert1
(
"no of tokens should be count"
,
i
==
count
,
"no of tokens %d count %d"
,
i
,
count
);
mytoken
=
tokens
[
0
];
MQTTClient_free
(
tokens
);
}
MQTTClient_destroy
(
&
c
);
/* force re-reading persistence on create */
...
...
test/test9.c
浏览文件 @
08132d4c
/*******************************************************************************
* Copyright (c) 2012, 202
2
IBM Corp., Ian Craggs
* Copyright (c) 2012, 202
3
IBM Corp., Ian Craggs
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
...
...
@@ -338,7 +338,7 @@ int test1_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync
MyLog
(
LOGA_DEBUG
,
"Message received on topic %s,
\"
%.*s
\"
"
,
topicName
,
message
->
payloadlen
,
message
->
payload
);
if
(
memcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
if
(
me
ssage
->
payloadlen
==
strlen
(
"will message"
)
&&
me
mcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
test1_will_message_received
=
1
;
else
test1_messages_received
++
;
...
...
@@ -599,7 +599,7 @@ int test2_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync
MyLog
(
LOGA_DEBUG
,
"Message received on topic %s,
\"
%.*s
\"
"
,
topicName
,
message
->
payloadlen
,
message
->
payload
);
if
(
memcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
if
(
me
ssage
->
payloadlen
==
strlen
(
"will message"
)
&&
me
mcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
test2_will_message_received
=
1
;
else
test2_messages_received
++
;
...
...
@@ -868,9 +868,9 @@ int test3_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync
MQTTAsync
c
=
(
MQTTAsync
)
context
;
static
int
message_count
=
0
;
MyLog
(
LOGA_DEBUG
,
"Message received on topic %s,
\"
%.*s
\"
"
,
topicName
,
message
->
payloadlen
,
message
->
payload
);
MyLog
(
LOGA_DEBUG
,
"Message received on topic %s,
\"
%.*s
\"
%d"
,
topicName
,
message
->
payloadlen
,
message
->
payload
,
message
->
payloadlen
);
if
(
memcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
if
(
me
ssage
->
payloadlen
==
strlen
(
"will message"
)
&&
me
mcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
test3_will_message_received
=
1
;
else
test3_messages_received
++
;
...
...
@@ -1129,7 +1129,7 @@ int test4_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync
MyLog
(
LOGA_DEBUG
,
"Message received on topic %s,
\"
%.*s
\"
"
,
topicName
,
message
->
payloadlen
,
message
->
payload
);
if
(
memcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
if
(
me
ssage
->
payloadlen
==
strlen
(
"will message"
)
&&
me
mcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
test4_will_message_received
=
1
;
else
test4_messages_received
++
;
...
...
@@ -1391,9 +1391,9 @@ int test5_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync
MQTTAsync
c
=
(
MQTTAsync
)
context
;
static
int
message_count
=
0
;
MyLog
(
LOGA_DEBUG
,
"Message received on topic %s,
\"
%.*s
\"
"
,
topicName
,
message
->
payloadlen
,
message
->
payload
);
MyLog
(
LOGA_DEBUG
,
"Message received on topic %s,
\"
%.*s
\"
%d"
,
topicName
,
message
->
payloadlen
,
message
->
payload
,
message
->
payloadlen
);
if
(
memcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
if
(
me
ssage
->
payloadlen
==
strlen
(
"will message"
)
&&
me
mcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
test5_will_message_received
=
1
;
else
test5_messages_received
++
;
...
...
@@ -1716,7 +1716,7 @@ int test6(struct Options options)
/* let client c go: connect, and send disconnect command to proxy */
opts
.
will
=
&
wopts
;
opts
.
will
->
payload
.
data
=
"will message"
;
opts
.
will
->
payload
.
len
=
(
int
)
strlen
(
opts
.
will
->
payload
.
data
)
+
1
;
opts
.
will
->
payload
.
len
=
(
int
)
strlen
(
opts
.
will
->
payload
.
data
);
opts
.
will
->
qos
=
1
;
opts
.
will
->
retained
=
0
;
opts
.
will
->
topicName
=
willTopic
;
...
...
@@ -1814,7 +1814,7 @@ int test7_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync
MyLog
(
LOGA_DEBUG
,
"Message received on topic %s,
\"
%.*s
\"
"
,
topicName
,
message
->
payloadlen
,
message
->
payload
);
if
(
memcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
if
(
me
ssage
->
payloadlen
==
strlen
(
"will message"
)
&&
me
mcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
test7_will_message_received
=
1
;
else
test7_messages_received
++
;
...
...
test/test95.c
浏览文件 @
08132d4c
/*******************************************************************************
* Copyright (c) 2012, 202
2
IBM Corp., Ian Craggs
* Copyright (c) 2012, 202
3
IBM Corp., Ian Craggs
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
...
...
@@ -383,7 +383,7 @@ int test1_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync
MyLog
(
LOGA_DEBUG
,
"Message received on topic %s,
\"
%.*s
\"
"
,
topicName
,
message
->
payloadlen
,
message
->
payload
);
if
(
memcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
if
(
me
ssage
->
payloadlen
==
strlen
(
"will message"
)
&&
me
mcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
test1_will_message_received
=
1
;
else
test1_messages_received
++
;
...
...
@@ -720,7 +720,7 @@ int test2_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync
MyLog
(
LOGA_DEBUG
,
"Message received on topic %s,
\"
%.*s
\"
"
,
topicName
,
message
->
payloadlen
,
message
->
payload
);
if
(
memcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
if
(
me
ssage
->
payloadlen
==
strlen
(
"will message"
)
&&
me
mcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
test2_will_message_received
=
1
;
else
test2_messages_received
++
;
...
...
@@ -992,7 +992,7 @@ int test3_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync
MyLog
(
LOGA_DEBUG
,
"Message received on topic %s,
\"
%.*s
\"
"
,
topicName
,
message
->
payloadlen
,
message
->
payload
);
if
(
memcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
if
(
me
ssage
->
payloadlen
==
strlen
(
"will message"
)
&&
me
mcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
test3_will_message_received
=
1
;
else
test3_messages_received
++
;
...
...
@@ -1260,7 +1260,7 @@ int test4_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync
MyLog
(
LOGA_DEBUG
,
"Message received on topic %s,
\"
%.*s
\"
"
,
topicName
,
message
->
payloadlen
,
message
->
payload
);
if
(
memcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
if
(
me
ssage
->
payloadlen
==
strlen
(
"will message"
)
&&
me
mcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
test4_will_message_received
=
1
;
else
test4_messages_received
++
;
...
...
@@ -1532,7 +1532,7 @@ int test5_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync
MyLog
(
LOGA_DEBUG
,
"Message received on topic %s,
\"
%.*s
\"
"
,
topicName
,
message
->
payloadlen
,
message
->
payload
);
if
(
memcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
if
(
me
ssage
->
payloadlen
==
strlen
(
"will message"
)
&&
me
mcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
test5_will_message_received
=
1
;
else
test5_messages_received
++
;
...
...
@@ -1869,7 +1869,7 @@ int test6(struct Options options)
/* let client c go: connect, and send disconnect command to proxy */
opts
.
will
=
&
wopts
;
opts
.
will
->
payload
.
data
=
"will message"
;
opts
.
will
->
payload
.
len
=
(
int
)
strlen
(
opts
.
will
->
payload
.
data
)
+
1
;
opts
.
will
->
payload
.
len
=
(
int
)
strlen
(
opts
.
will
->
payload
.
data
);
opts
.
will
->
qos
=
1
;
opts
.
will
->
retained
=
0
;
opts
.
will
->
topicName
=
willTopic
;
...
...
@@ -1970,7 +1970,7 @@ int test7_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync
MyLog
(
LOGA_DEBUG
,
"Message received on topic %s,
\"
%.*s
\"
"
,
topicName
,
message
->
payloadlen
,
message
->
payload
);
if
(
memcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
if
(
me
ssage
->
payloadlen
==
strlen
(
"will message"
)
&&
me
mcmp
(
message
->
payload
,
"will message"
,
message
->
payloadlen
)
==
0
)
test7_will_message_received
=
1
;
else
test7_messages_received
++
;
...
...