Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix h-b-o #1720 #906

Merged
merged 5 commits into from
Mar 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/sp/protocol/mqtt/mqtt_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,16 +583,16 @@ conn_handler(uint8_t *packet, conn_param *cparam, size_t max)
NNI_GET16(packet + pos, tmp);
cparam->keepalive_mqtt = tmp;
pos += 2;
// properties

// properties
if (cparam->pro_ver == MQTT_PROTOCOL_VERSION_v5) {
// check length
log_trace("Decoding MQTT V5 Properties");
if (pos >= max)
if (pos + 4 >= max)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 == 2 (property len) + 2 (clientid len). Am I right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's the req of get_var_integer.

return PROTOCOL_ERROR;
cparam->prop_len = (uint32_t) get_var_integer(packet + pos,
&len_of_var);
if (cparam->prop_len > (max - pos - 1 - cparam->will_flag*2 ))
if (cparam->prop_len > (max - pos - 1 - cparam->will_flag * 2 ))
return PROTOCOL_ERROR;
log_debug("remain len %d max len %d prop len %d pos %d",
len, max, cparam->prop_len, pos);
Expand All @@ -610,7 +610,7 @@ conn_handler(uint8_t *packet, conn_param *cparam, size_t max)

// here starts payload: client_id
cparam->clientid.body =
(char *) copyn_utf8_str(packet, &pos, &len_of_str, max-pos);
(char *) copyn_utf8_str(packet, &pos, &len_of_str, max - pos);
cparam->clientid.len = len_of_str;

if (len_of_str == 0) {
Expand Down
Loading