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

Issue with new client metrics #115

Closed
Borschtsch opened this issue Dec 9, 2017 · 1 comment
Closed

Issue with new client metrics #115

Borschtsch opened this issue Dec 9, 2017 · 1 comment
Labels

Comments

@Borschtsch
Copy link

Borschtsch commented Dec 9, 2017

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 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

@chaurah
Copy link
Contributor

chaurah commented Dec 11, 2017

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.

Rahul

gordonwang0 pushed a commit that referenced this issue Apr 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants