From d2dc05b01ecd3722468b1c4dc38bb963f7321fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 30 Jul 2014 07:44:25 +0200 Subject: core: check that from/to arguments are not NULL in base16/64 functions --- src/core/wee-string.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/core/wee-string.c b/src/core/wee-string.c index 4c893c9f5..de4443773 100644 --- a/src/core/wee-string.c +++ b/src/core/wee-string.c @@ -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; -- cgit v1.2.3