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 [mqtt_codec] var max pos is 5 instead of 4 #1079

Merged
merged 1 commit into from
Oct 12, 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/supplemental/mqtt/mqtt_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,8 +738,8 @@ nni_mqtt_msg_append_varint(nni_msg *msg, uint32_t val)
log_warn("variable value overflow!");
return -1;
}
uint8_t buf[4] = { 0 };
struct pos_buf pbuf = { .curpos = &buf[0], .endpos = &buf[3] };
uint8_t buf[5] = { 0 };
struct pos_buf pbuf = { .curpos = &buf[0], .endpos = &buf[4] };
int bytes = write_variable_length_value(val, &pbuf);
if (bytes > -1) {
nni_msg_append(msg, buf, bytes);
Expand Down Expand Up @@ -2847,9 +2847,9 @@ write_variable_length_value(uint32_t value, struct pos_buf *buf)
}
*(buf->curpos++) = byte;
count++;
} while (value > 0 && count < 4);
} while (value > 0 && count < 5);

if (count == 4) {
if (count == 5) {
return -1;
}
return count;
Expand Down
Loading