-
Notifications
You must be signed in to change notification settings - Fork 187
Fix MQTT client: clear credentials and will on connection teardown #402
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -1950,13 +1950,6 @@ UCHAR fixed_header; | |
| client_ptr -> nxd_mqtt_ping_sent_time = 0; | ||
| } | ||
|
|
||
| /* Clean up the information when disconnecting. */ | ||
| client_ptr -> nxd_mqtt_client_username = NX_NULL; | ||
| client_ptr -> nxd_mqtt_client_password = NX_NULL; | ||
| client_ptr -> nxd_mqtt_client_will_topic = NX_NULL; | ||
| client_ptr -> nxd_mqtt_client_will_message = NX_NULL; | ||
| client_ptr -> nxd_mqtt_client_will_qos_retain = 0; | ||
|
|
||
| /* Release current processing packet. */ | ||
| if (client_ptr -> nxd_mqtt_client_processing_packet) | ||
| { | ||
|
|
@@ -2571,6 +2564,14 @@ VOID _nxd_mqtt_client_connection_end(NXD_MQTT_CLIENT *client_ptr, ULONG wait_opt | |
| nx_tcp_socket_disconnect(&(client_ptr -> nxd_mqtt_client_socket), wait_option); | ||
| nx_tcp_client_socket_unbind(&(client_ptr -> nxd_mqtt_client_socket)); | ||
|
|
||
| /* Clean up per-connection information so a failed or ended connection | ||
| never leaks credentials or will settings into the next CONNECT. */ | ||
| client_ptr -> nxd_mqtt_client_username = NX_NULL; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| client_ptr -> nxd_mqtt_client_password = NX_NULL; | ||
| client_ptr -> nxd_mqtt_client_will_topic = NX_NULL; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| client_ptr -> nxd_mqtt_client_will_message = NX_NULL; | ||
| client_ptr -> nxd_mqtt_client_will_qos_retain = 0; | ||
|
|
||
|
Comment on lines
+2567
to
+2574
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| /* Disable timer if timer has been started. */ | ||
| if (client_ptr -> nxd_mqtt_keepalive) | ||
| { | ||
|
|
@@ -3750,9 +3751,19 @@ UINT old_priority; | |
| { | ||
| nx_secure_tls_session_delete(&(client_ptr -> nxd_mqtt_tls_session)); | ||
| } | ||
| client_ptr -> nxd_mqtt_client_use_tls = 0; | ||
| #endif /* NX_SECURE_ENABLE */ | ||
| nx_tcp_client_socket_unbind(&(client_ptr -> nxd_mqtt_client_socket)); | ||
| tx_timer_delete(&(client_ptr -> nxd_mqtt_timer)); | ||
|
|
||
| /* Same per-connection cleanup as _nxd_mqtt_client_connection_end — | ||
| this early-failure path is the only teardown that does not go | ||
| through it. */ | ||
| client_ptr -> nxd_mqtt_client_username = NX_NULL; | ||
| client_ptr -> nxd_mqtt_client_password = NX_NULL; | ||
| client_ptr -> nxd_mqtt_client_will_topic = NX_NULL; | ||
| client_ptr -> nxd_mqtt_client_will_message = NX_NULL; | ||
| client_ptr -> nxd_mqtt_client_will_qos_retain = 0; | ||
| return(NXD_MQTT_CONNECT_FAILURE); | ||
| } | ||
|
|
||
|
|
||
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.