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

Failed to compile on esp-idf due to set method. #108

Open
GioTB opened this issue Oct 20, 2022 · 1 comment
Open

Failed to compile on esp-idf due to set method. #108

GioTB opened this issue Oct 20, 2022 · 1 comment

Comments

@GioTB
Copy link

GioTB commented Oct 20, 2022

I´m using the library on esp-idf on a esp32, and i´m having the following error on compile:

TinyGPSPlus/src/TinyGPS++.cpp:487:10: error: 'char* strncpy(char*, const char*, size_t)' specified bound 16 equals destination size [-Werror=stringop-truncation]
strncpy(this->stagingBuffer, term, sizeof(this->stagingBuffer));

has i can see the strncpy on the Set method should have a "-1" size so the destination buffer always contains the null character.
For now i modified it to compile by leaving the strncpy like this:

void TinyGPSCustom::set(const char *term)
{
strncpy(this->stagingBuffer, term, sizeof(this->stagingBuffer) - 1);
}
i hadded the "-1" on the size parameter, i saw the stagingBuffer and i realized that it´s size it´s +1 of _GPS_MAX_FIELD_SIZE wich i suppose it´s precisely for the null character so there shouldn´t be any problem.

If this is right, please add it to the repo!

Thanks!!!!

@dbcook
Copy link

dbcook commented Nov 9, 2023

There is a buffer overflow security problem here if _GPS_MAX_FIELD_SIZE could ever be exceeded on the input, so (size-1) on the strncpy 3rd arg is always good hygiene. As this repo seems to have gone inactive I'm going to grab @GioTB 's fork and use that.

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