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

mqttClient allows calling connect without set clientName, yields out of memory error #2896

Closed
pljakobs opened this issue Oct 25, 2024 · 1 comment

Comments

@pljakobs
Copy link
Contributor

mqttClient::connect uses copyString to copy the clientName into the protocol header. copyString tries

	destBuffer.data = (uint8_t*)MQTT_MALLOC(sourceString.length());

which, for a zero byte string will return, if I understand correctly, nullptr
(and also trigers an M:0 from the ESP)

	if(destBuffer.data == nullptr) {
		debug_e("Not enough memory");
		return false;
	}

will be true and the connect will fail.

I guess one way to avoid that is to guard against an empty clientName in mqttClient::connect. I'll have a better look and submit a pr if that is the only place this fails.

@pljakobs
Copy link
Contributor Author

I think this should do it #2897

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