roken: Use calloc() for overflow det. in hex_encode
Using calloc() means setting errno on overflow instead of not.
This commit is contained in:
@@ -58,13 +58,7 @@ hex_encode(const void *data, size_t size, char **str)
|
|||||||
size_t i;
|
size_t i;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
/* check for overflow */
|
p = calloc(size + 1, 2);
|
||||||
if (size * 2 < size) {
|
|
||||||
*str = NULL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = malloc(size * 2 + 1);
|
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
*str = NULL;
|
*str = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
|
Reference in New Issue
Block a user