diff options
author | Steve Holme <steve_holme@hotmail.com> | 2013-12-01 11:05:11 +0000 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2013-12-01 11:12:23 +0000 |
commit | c92c30edbde3b7f7562c2bcb4a06626781c55f1d (patch) | |
tree | 35dd53ca41b258aeee016752a31d28d7b3c366e2 /tests/unit | |
parent | 4d10f486293ffa127cc6cd607e4c1af70c4f2282 (diff) |
base64: Extended validation to look for invalid characters
Extended the basic validation in commit e17c1b25bc33eb to return a
failure when invalid base64 characters are included.
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/unit1302.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/unit/unit1302.c b/tests/unit/unit1302.c index b5688f047..6886af8c4 100644 --- a/tests/unit/unit1302.c +++ b/tests/unit/unit1302.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -31,7 +31,7 @@ static struct SessionHandle *data; static CURLcode unit_setup( void ) { data = curl_easy_init(); - if (!data) + if(!data) return CURLE_OUT_OF_MEMORY; return CURLE_OK; } @@ -128,13 +128,12 @@ fail_unless(rc == CURLE_BAD_CONTENT_ENCODING, "return code should be CURLE_BAD_C fail_unless(size == 0, "size should be 0"); fail_if(decoded, "returned pointer should be NULL"); -/* this is garbage input that libcurl decodes as far as possible */ -size = 0; -decoded = NULL; +/* This is garbage input as it contains an illegal base64 character */ +size = 1; /* not zero */ +decoded = &anychar; /* not NULL */ rc = Curl_base64_decode("a\x1f==", &decoded, &size); -fail_unless(rc == CURLE_OK, "return code should be CURLE_OK"); -fail_unless(size == 1, "size should be 1"); -fail_if(!decoded, "returned pointer should not be NULL"); -Curl_safefree(decoded); +fail_unless(rc == CURLE_BAD_CONTENT_ENCODING, "return code should be CURLE_BAD_CONTENT_ENCODING"); +fail_unless(size == 0, "size should be 0"); +fail_if(decoded, "returned pointer should be NULL"); UNITTEST_STOP |