mirror of
https://github.com/clearlinux/graphene.git
synced 2026-10-04 16:08:22 +00:00
Fix off-by-one error in __hex2str() (#130)
This commit is contained in:
committed by
Don Porter
parent
ce49dcb03d
commit
529a4ba3cb
@@ -158,7 +158,7 @@ static inline __attribute__((always_inline))
|
||||
char * __hex2str(void * hex, int size)
|
||||
{
|
||||
static char * ch = "0123456789abcdef";
|
||||
char * str = __alloca(size * 2);
|
||||
char * str = __alloca(size * 2 + 1);
|
||||
|
||||
for (int i = 0 ; i < size ; i++) {
|
||||
unsigned char h = ((unsigned char *) hex)[i];
|
||||
@@ -166,7 +166,7 @@ char * __hex2str(void * hex, int size)
|
||||
str[i * 2 + 1] = ch[h % 16];
|
||||
}
|
||||
|
||||
str[size * 2 - 1] = 0;
|
||||
str[size * 2] = 0;
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user