Commit f2affbd9 authored by Rico Ganahl's avatar Rico Ganahl Committed by Martí Bolívar
Browse files

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: default avatarRico Ganahl <rico.ganahl@bytesatwork.ch>
parent b53657a0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
	}