-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix 5 bugs: asn1_encode threshold, MQTT bounds/mid, unpack underflow, null deref #815
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
1ef15a2
d709bc0
2bdf6f1
3e30f13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,8 @@ | |
|
|
||
| static unsigned short mqtt_next_mid() { | ||
| static unsigned short s_mid = 0; | ||
| return ++s_mid; | ||
| if (++s_mid == 0) s_mid = 1; | ||
| return s_mid; | ||
| } | ||
|
||
|
|
||
| static int mqtt_client_send(mqtt_client_t* cli, const void* buf, int len) { | ||
|
|
@@ -231,6 +232,7 @@ static void mqtt_client_add_reconnect_timer(mqtt_client_t* cli) { | |
|
|
||
| static void on_close(hio_t* io) { | ||
| mqtt_client_t* cli = (mqtt_client_t*)hevent_userdata(io); | ||
| if (cli == NULL) return; | ||
| cli->connected = 0; | ||
| if (cli->cb) { | ||
| cli->head.type = MQTT_TYPE_DISCONNECT; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
signed_package_lenis computed and compared usingintcasts. This can overflow (or mis-compare) ifpackage_max_lengthis set aboveINT_MAX, since(int)setting->package_max_lengthbecomes negative. Consider computing length inint64_t(orlong long) and comparing againstsetting->package_max_lengthwithout narrowing; also consider settingio->errortoERR_INVALID_PACKAGEwhen the computed length is <= 0, reservingERR_OVER_LIMITfor the > max-length case.