core: check that from/to arguments are not NULL in base16/64 functions

v2.8-utf8proc
Sébastien Helleu 2014-07-30 07:44:25 +02:00
parent 3d6b9ff5a7
commit d2dc05b01e
1 changed files with 12 additions and 0 deletions

View File

@ -2338,6 +2338,9 @@ string_encode_base16 (const char *from, int length, char *to)
const char *hexa = "0123456789ABCDEF";
char *ptr_to;
if (!from || !to)
return;
ptr_to = to;
ptr_to[0] = '\0';
for (i = 0; i < length; i++)
@ -2361,6 +2364,9 @@ string_decode_base16 (const char *from, char *to)
int length, to_length, i, pos;
unsigned char *ptr_to, value;
if (!from || !to)
return 0;
length = strlen (from) / 2;
ptr_to = (unsigned char *)to;
@ -2425,6 +2431,9 @@ string_encode_base64 (const char *from, int length, char *to)
const char *ptr_from;
char *ptr_to;
if (!from || !to)
return;
ptr_from = from;
ptr_to = to;
@ -2487,6 +2496,9 @@ string_decode_base64 (const char *from, char *to)
unsigned char base64_table[]="|$$$}rstuvwxyz{$$$$$$$>?"
"@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq";
if (!from || !to)
return 0;
ptr_from = from;
ptr_to = to;