From da6dda795bb62c01e290a4b1d8ed09f3878ae36c Mon Sep 17 00:00:00 2001 From: TLINDEN Date: Thu, 9 Jul 2015 18:37:33 +0200 Subject: [PATCH] fixed error return to 0, -1 lead to int overflows --- libpcp/util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libpcp/util.c b/libpcp/util.c index f3e502a..11f9302 100644 --- a/libpcp/util.c +++ b/libpcp/util.c @@ -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; } }