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

segfault on secure URI with no SSL options supplied #1566

Open
fpagliughi opened this issue Jan 18, 2025 · 1 comment
Open

segfault on secure URI with no SSL options supplied #1566

fpagliughi opened this issue Jan 18, 2025 · 1 comment

Comments

@fpagliughi
Copy link
Contributor

fpagliughi commented Jan 18, 2025

Describe the bug

If a secure URI, like mqtts://... is supplied to the the serverURIs field of the MQTTAsync_connectOptions, but no SSL options given to the connect options (i.e. conn_opts.ssl == NULL), then the program segfaults.

To Reproduce

Take a sample app, like MQTTAsync_publish.c

Set the URI as an empty string in the call to create the client:

if ((rc = MQTTAsync_create(&client, "", CLIENTID, MQTTCLIENT_PERSISTENCE_NONE, NULL)) != MQTTASYNC_SUCCESS)
{ ...

The add a secure URI to the connect options without specifying SSL options, like:

char* const uris[] = {"mqtts://test.mosquitto.org:8883"};

conn_opts.serverURIcount = 1;
conn_opts.serverURIs = uris;

conn_opts.keepAliveInterval = 20;
conn_opts.cleansession = 1;
conn_opts.onSuccess = onConnect;
conn_opts.onFailure = onConnectFailure;
conn_opts.context = client;

if ((rc = MQTTAsync_connect(client, &conn_opts)) != MQTTASYNC_SUCCESS)
{ ...

The call to MQTTAsync_connect() crashes with a segfault.

Expected behavior
Return -6 from the call to MQTTAsync_connect() in this case.

@fpagliughi
Copy link
Contributor Author

Note that this was originally reported on the Paho Rust repo:
eclipse-paho/paho.mqtt.rust#238

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant