os: lib: bin2hex: fix memory overwrite
Destination buffer size could be too small by one, but null termination is still written. This could cause an overwrite in contiguous memory without notice. Signed-off-by: Rico Ganahl <rico.ganahl@bytesatwork.ch>
This commit is contained in:
parent
b53657a058
commit
f2affbd973
1 changed files with 1 additions and 1 deletions
|
@ -39,7 +39,7 @@ int hex2char(uint8_t x, char *c)
|
|||
|
||||
size_t bin2hex(const uint8_t *buf, size_t buflen, char *hex, size_t hexlen)
|
||||
{
|
||||
if ((hexlen + 1) < buflen * 2) {
|
||||
if (hexlen < (buflen * 2 + 1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue