File tree Expand file tree Collapse file tree 3 files changed +10
-9
lines changed Expand file tree Collapse file tree 3 files changed +10
-9
lines changed Original file line number Diff line number Diff line change 66# is set, UNIX family socket will be used
77
88ip_address 127.0.0.1
9- ip_port 8883
9+ ip_port 1883 # 8883 for MQTT over TLS (MQTT clients such as mosquitto will automatically add TLS)
1010
1111# unix_socket /tmp/sol.sock
1212
Original file line number Diff line number Diff line change @@ -238,31 +238,34 @@ int publish_message(struct mqtt_packet *pkt, const struct topic *t)
238238}
239239
240240/*
241- * Check if a topic match a wildcard subscription. It works with + and # as
241+ * Check if a topic matches a wildcard subscription. It works with + and # as
242242 * well
243243 */
244- static inline int match_subscription (const char * topic , const char * wtopic ,
245- bool multilevel )
244+ static int match_subscription (const char * topic , const char * wtopic ,
245+ bool multilevel )
246246{
247247 size_t len = strlen (wtopic );
248248 int i = 0 , j = 0 ;
249249 bool found = false;
250250 char * ptopic = (char * )topic ;
251+
252+ if (!ptopic )
253+ return - SOL_ERR ;
254+
251255 /*
252256 * Cycle through the wildcard topic, char by char, seeking for '+' char and
253257 * at the same time assuring that every char is equal in the topic as well,
254258 * we don't want to accept different topics
255259 */
256260 while (i < len && wtopic [i ]) {
257261 j = 0 ;
258- for (; i < len ; ++ i ) {
262+ for (; i < len ; ++ i , ++ j ) {
259263 if (wtopic [i ] == '+' ) {
260264 found = true;
261265 break ;
262- } else if (! ptopic || ( wtopic [i ] != ptopic [j ]) ) {
266+ } else if (wtopic [i ] != ptopic [j ]) {
263267 return - SOL_ERR ;
264268 }
265- j ++ ;
266269 }
267270 /*
268271 * Get a pointer to the next '/', called two times because we want to
Original file line number Diff line number Diff line change 3737#include <errno.h>
3838#include <fcntl.h>
3939#include <pthread.h>
40- #include <sys/event.h>
4140#include <unistd.h>
4241
4342#define BUFSIZE 2048
@@ -432,7 +431,6 @@ static inline int write_data(Connection_Context *c)
432431{
433432 ssize_t wrote = send_data (& c -> conn , c -> send_buf + c -> written ,
434433 c -> write_total - c -> written );
435- printf ("WEWEW %s (%zu)\n" , c -> cid , wrote );
436434 if (errno != EAGAIN && errno != EWOULDBLOCK && wrote < 0 )
437435 goto e_client_dc ;
438436 c -> written += wrote > 0 ? wrote : 0 ;
You can’t perform that action at this time.
0 commit comments