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

Bug in the send packet function #66

Closed
Borschtsch opened this issue Jan 5, 2017 · 1 comment
Closed

Bug in the send packet function #66

Borschtsch opened this issue Jan 5, 2017 · 1 comment

Comments

@Borschtsch
Copy link

Borschtsch commented Jan 5, 2017

Hello,

There is a bug in aws_iot_mqtt_internal_send_packet() function.

If network stack write function is not able to send the full packet size (say there is a limitation on the network stack side which only allows to send 256 bytes at a time), the send function will try to send the rest of the write buffer in the socket until it send all the data. The function will adjust the pointer to the write buffer, but will not adjust the length of the data left on the buffer. Potentially it may lead to accessing data outside of the write buffer, but in my case it also breaks the code.

sentLen = 0;
sent = 0;

while(sent < length && !has_timer_expired(pTimer)) {
	rc = pClient->networkStack.write(&(pClient->networkStack), 
				&pClient->clientData.writeBuf[sent], ===> length <===, pTimer,
				&sentLen);
	if(SUCCESS != rc) {
		/* there was an error writing the data */
		break;
	}
            
	sent += sentLen;
}

Thanks,
-Dmitry

@chaurah
Copy link
Contributor

chaurah commented Jan 5, 2017

Hi @Borschtsch,
Thank you for pointing this out. I have made a note of this in our internal bug tracker and we will include a fix for this issue in the next version of the SDK. The fix should be simply using "length - sent" instead of length in the write call.

Please do let us know if you have any further suggestions for improvements to the SDK. Your feedback is very important. Thank you for using AWS IoT.

Rahul

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

2 participants