Skip to content

Commit

Permalink
[487178] Obey mount_point when publishing wills.
Browse files Browse the repository at this point in the history
Wills published by clients connected to a listener with mount_point defined
now correctly obey the mount point. This was a potential security risk
because it allowed clients to publish messages outside of their restricted
mount point. This is only affects brokers where the mount_point option is in
use.

Thanks to Lance Riley.

Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=487178
  • Loading branch information
ralight committed Feb 11, 2016
1 parent 9497dab commit eb514c9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
Broker:
- Wills published by clients connected to a listener with mount_point defined
now correctly obey the mount point. This was a potential security risk
because it allowed clients to publish messages outside of their restricted
mount point. This is only affects brokers where the mount_point option is in
use. Closes #487178.
- Fix detection of broken connections on Windows. Closes #485143.

Client library:
Expand Down
16 changes: 16 additions & 0 deletions src/read_handle_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ int mqtt3_handle_connect(struct mosquitto_db *db, struct mosquitto *context)
uint8_t connect_ack = 0;
char *client_id = NULL;
char *will_payload = NULL, *will_topic = NULL;
char *will_topic_mount;
uint16_t will_payloadlen;
struct mosquitto_message *will_struct = NULL;
uint8_t will, will_retain, will_qos, clean_session;
Expand Down Expand Up @@ -240,6 +241,21 @@ int mqtt3_handle_connect(struct mosquitto_db *db, struct mosquitto *context)
rc = 1;
goto handle_connect_error;
}

if(context->listener && context->listener->mount_point){
slen = strlen(context->listener->mount_point) + strlen(will_topic);
will_topic_mount = _mosquitto_malloc(slen+1);
if(!will_topic_mount){
rc = MOSQ_ERR_NOMEM;
goto handle_connect_error;
}
snprintf(will_topic_mount, slen, "%s%s", context->listener->mount_point, will_topic);
will_topic_mount[slen] = '\0';

_mosquitto_free(will_topic);
will_topic = will_topic_mount;
}

if(mosquitto_pub_topic_check(will_topic)){
rc = 1;
goto handle_connect_error;
Expand Down

0 comments on commit eb514c9

Please sign in to comment.