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

buffer overflow hazards #38

Open
petesoper opened this issue Jul 4, 2018 · 1 comment
Open

buffer overflow hazards #38

petesoper opened this issue Jul 4, 2018 · 1 comment

Comments

@petesoper
Copy link

This current code allows MAX_VALUES + 1 data sets to be copied into the val buffer, overwriting memory after its end. The limit check should be BEFORE the copies and it should be checking for current_value already being at MAX_VALUES, not greater, sine currentValue is the (effective) array index.

void Ubidots::add(char *variable_id, double value, char *ctext, long unsigned timestamp_val) { _dirty = true; (val + _currentValue)->idName = variable_id; (val + _currentValue)->idValue = value; (val + _currentValue)->contextOne = ctext; (val + _currentValue)->timestamp_val = timestamp_val; _currentValue++; if (_currentValue > MAX_VALUES) { Serial.println(F("You are sending more than the maximum of consecutive variables")); _currentValue = MAX_VALUES; } }
In addition, is snprintf not available for the environments using this code? Even if it isn't, using the return value of sprintf in sendAll and editing into a local buffer would allow avoiding overflow of the allData buffer. As a side effect, this checking would constitute part of the setup for avoiding recopying allData onto itself and concatenating new strings over and over and OVER. Should this useless copying be part of an application expected to conserve power?

@petesoper
Copy link
Author

I swear I put that code inside code delimiters. Sorry it's not readable, but just look for the function in the library .cpp file.

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