core: return -1 in case of error in functions string_base16_decode and string_base64_decode

This commit is contained in:
Sébastien Helleu 2020-05-21 00:01:35 +02:00
parent 8f308ea918
commit 0ac936a5cf
2 changed files with 8 additions and 8 deletions

View File

@ -2954,7 +2954,7 @@ string_base16_decode (const char *from, char *to)
unsigned char value; unsigned char value;
if (!from || !to) if (!from || !to)
return 0; return -1;
count = 0; count = 0;
@ -3251,7 +3251,7 @@ string_base64_decode (const char *from, char *to)
"@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq"; "@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq";
if (!from || !to) if (!from || !to)
return 0; return -1;
ptr_from = from; ptr_from = from;
ptr_to = to; ptr_to = to;

View File

@ -1705,9 +1705,9 @@ TEST(CoreString, Base16)
} }
/* string_base16_decode */ /* string_base16_decode */
LONGS_EQUAL(0, string_base16_decode (NULL, NULL)); LONGS_EQUAL(-1, string_base16_decode (NULL, NULL));
LONGS_EQUAL(0, string_base16_decode (NULL, str)); LONGS_EQUAL(-1, string_base16_decode (NULL, str));
LONGS_EQUAL(0, string_base16_decode ("", NULL)); LONGS_EQUAL(-1, string_base16_decode ("", NULL));
LONGS_EQUAL(0, string_base16_decode ("", str)); LONGS_EQUAL(0, string_base16_decode ("", str));
for (i = 0; str_base16[i][0]; i++) for (i = 0; str_base16[i][0]; i++)
{ {
@ -1828,9 +1828,9 @@ TEST(CoreString, Base64)
} }
/* string_base64_decode */ /* string_base64_decode */
LONGS_EQUAL(0, string_base64_decode (NULL, NULL)); LONGS_EQUAL(-1, string_base64_decode (NULL, NULL));
LONGS_EQUAL(0, string_base64_decode (NULL, str)); LONGS_EQUAL(-1, string_base64_decode (NULL, str));
LONGS_EQUAL(0, string_base64_decode ("", NULL)); LONGS_EQUAL(-1, string_base64_decode ("", NULL));
LONGS_EQUAL(0, string_base64_decode ("", str)); LONGS_EQUAL(0, string_base64_decode ("", str));
for (i = 0; str_base64[i][0]; i++) for (i = 0; str_base64[i][0]; i++)
{ {