You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found couple issues with aws_iot_mqtt_connect() function when client metrics string is being passed into the connect call.
The temp client metrics string is defined as a function local variable. char pUsernameTemp[SDK_METRICS_LEN] = {0};
Then it is passed to the connection parameters by the pointer. pConnectParams->pUsername = (char*)&pUsernameTemp;
First issue is that code should not take an address of a pUsernameTemp as it is already a pointer to the string, or maybe the intent was to do &pUsernameTemp[0]?
Second issue is less severe. After connection attempt pConnectParams->pUsername keeps a reference to the local variable which existed only in the context of the aws_iot_mqtt_connect() execution. The library does not use this value after, but a library user may decide to bring it in his code an do something like logging or whatever.
I think it would be good to either make some clean-up after use or declare the metrics string as a static variable.
Thanks,
-Dmitry
The text was updated successfully, but these errors were encountered:
Hi @Borschtsch,
Thank you for pointing this out. We will work on a path for this and put out a bugfix release soon. Please do let us know if you have any further concerns.
Hello!
I found couple issues with
aws_iot_mqtt_connect()
function when client metrics string is being passed into the connect call.The temp client metrics string is defined as a function local variable.
char pUsernameTemp[SDK_METRICS_LEN] = {0};
Then it is passed to the connection parameters by the pointer.
pConnectParams->pUsername = (char*)&pUsernameTemp;
First issue is that code should not take an address of a pUsernameTemp as it is already a pointer to the string, or maybe the intent was to do
&pUsernameTemp[0]
?Second issue is less severe. After connection attempt
pConnectParams->pUsername
keeps a reference to the local variable which existed only in the context of theaws_iot_mqtt_connect()
execution. The library does not use this value after, but a library user may decide to bring it in his code an do something like logging or whatever.I think it would be good to either make some clean-up after use or declare the metrics string as a static variable.
Thanks,
-Dmitry
The text was updated successfully, but these errors were encountered: