JSC-electronics / Adeon

C++ library for processing commands from Adeon android mobile app.
Apache License 2.0
0 stars 0 forks source link

Accessing array out of bounds #5

Closed vzahradnik closed 3 years ago

vzahradnik commented 3 years ago

.pio/libdeps/m5stack-core-esp32/Adeon/src/AdeonGSM.cpp: In member function 'bool Adeon::Parser::isHashParsingValid()': .pio/libdeps/m5stack-core-esp32/Adeon/src/AdeonGSM.cpp:358:25: warning: array subscript is above array bounds [-Warray-bounds] _tmpHash[hashLen] = _nullChar;

vzahradnik commented 3 years ago

I fixed the issue in b884af1. However, @Robert-Faltus please check if I did it correctly.

You allocated an array to store short hash of 5 bytes, and then you wrote \0 character as a 6-th byte. I increased the size of an array. However, if the hash should be 5 bytes including the \0 character, then my fix is wrong.

vzahradnik commented 3 years ago

OK, so short hash has 5 characters, e.g., e4917. Therefore, my fix is correct. I store the \0 character at the end.