mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 20:00:58 +01:00
fixed error return to 0, -1 lead to int overflows
This commit is contained in:
@@ -95,7 +95,7 @@ size_t _hex2bin(const char *hex_str, unsigned char *byte_array, size_t byte_arra
|
||||
if (byte_array_size > byte_array_max)
|
||||
{
|
||||
// Too big for the output array
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (hex_str_len % 2 == 1)
|
||||
@@ -103,7 +103,7 @@ size_t _hex2bin(const char *hex_str, unsigned char *byte_array, size_t byte_arra
|
||||
// hex_str is an odd length, so assume an implicit "0" prefix
|
||||
if (sscanf(&(hex_str[0]), "%1hhx", &(byte_array[0])) != 1)
|
||||
{
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = j = 1;
|
||||
@@ -113,7 +113,7 @@ size_t _hex2bin(const char *hex_str, unsigned char *byte_array, size_t byte_arra
|
||||
{
|
||||
if (sscanf(&(hex_str[i]), "%2hhx", &(byte_array[j])) != 1)
|
||||
{
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user