diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-08-26 08:30:38 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-08-27 14:17:36 +0200 |
commit | 6ebe63fac23f38df911edc348e8ccc72280f9434 (patch) | |
tree | c1bb753c9f971a177e8fa02d4d630d81d1bac924 /tests | |
parent | 9ee5701f12818e455c898c1a660cfd11d7e46518 (diff) | |
download | curl-6ebe63fac23f38df911edc348e8ccc72280f9434.tar.gz |
options: API for meta-data about easy options
const struct curl_easyoption *curl_easy_option_by_name(const char *name);
const struct curl_easyoption *curl_easy_option_by_id (CURLoption id);
const struct curl_easyoption *
curl_easy_option_next(const struct curl_easyoption *prev);
The purpose is to provide detailed enough information to allow for
example libcurl bindings to get option information at run-time about
what easy options that exist and what arguments they expect.
Assisted-by: Jeroen Ooms
Closes #5365
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/Makefile.inc | 2 | ||||
-rw-r--r-- | tests/data/test1119 | 1 | ||||
-rw-r--r-- | tests/data/test1911 | 31 | ||||
-rw-r--r-- | tests/libtest/Makefile.inc | 6 | ||||
-rw-r--r-- | tests/libtest/lib1911.c | 87 | ||||
-rwxr-xr-x | tests/libtest/mk-lib1521.pl | 10 | ||||
-rwxr-xr-x | tests/symbol-scan.pl | 2 |
7 files changed, 131 insertions, 8 deletions
diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc index c13fb7307..fa84a9560 100644 --- a/tests/data/Makefile.inc +++ b/tests/data/Makefile.inc @@ -207,7 +207,7 @@ test1700 test1701 test1702 \ test1800 test1801 \ \ test1900 test1901 test1902 test1903 test1904 test1905 test1906 test1907 \ -test1908 test1909 test1910 \ +test1908 test1909 test1910 test1911 \ \ test2000 test2001 test2002 test2003 test2004 test2005 test2006 test2007 \ test2008 test2009 test2010 test2011 test2012 test2013 test2014 test2015 \ diff --git a/tests/data/test1119 b/tests/data/test1119 index 5fb3c944a..2f1b54c23 100644 --- a/tests/data/test1119 +++ b/tests/data/test1119 @@ -27,5 +27,4 @@ Verify that symbols-in-versions and headers are in sync OK </stdout> </verify> - </testcase> diff --git a/tests/data/test1911 b/tests/data/test1911 new file mode 100644 index 000000000..78f0b8d8f --- /dev/null +++ b/tests/data/test1911 @@ -0,0 +1,31 @@ +<testcase> +<info> +<keywords> +curl_easy_option +</keywords> +</info> + +# Server-side +<reply> + +</data> +</reply> + +# Client-side +<client> +<server> +none +</server> +<name> +verify that curl_easy_setopt() rejects too long string inputs +</name> +<tool> +lib1911 +</tool> + +</client> + +# Verify data after the test has been "shot" +<verify> +</verify> +</testcase> diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 2c9c66539..576c88a86 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -58,7 +58,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \ lib1550 lib1551 lib1552 lib1553 lib1554 lib1555 lib1556 lib1557 \ lib1558 lib1559 lib1560 lib1564 lib1565 lib1567 \ lib1591 lib1592 lib1593 lib1594 lib1596 \ - lib1900 lib1905 lib1906 lib1907 lib1908 lib1910 \ + lib1900 lib1905 lib1906 lib1907 lib1908 lib1910 lib1911 \ lib2033 lib3010 chkdecimalpoint_SOURCES = chkdecimalpoint.c ../../lib/mprintf.c \ @@ -649,6 +649,10 @@ lib1910_SOURCES = lib1910.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib1910_LDADD = $(TESTUTIL_LIBS) lib1910_CPPFLAGS = $(AM_CPPFLAGS) +lib1911_SOURCES = lib1911.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib1911_LDADD = $(TESTUTIL_LIBS) +lib1911_CPPFLAGS = $(AM_CPPFLAGS) + lib2033_SOURCES = libntlmconnect.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib2033_LDADD = $(TESTUTIL_LIBS) lib2033_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_PIPELINING diff --git a/tests/libtest/lib1911.c b/tests/libtest/lib1911.c new file mode 100644 index 000000000..3fafd286a --- /dev/null +++ b/tests/libtest/lib1911.c @@ -0,0 +1,87 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2020, 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 + * are also available at https://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ +#include "test.h" + +#include "testutil.h" +#include "warnless.h" +#include "memdebug.h" + +/* The maximum string length limit (CURL_MAX_INPUT_LENGTH) is an internal + define not publicly exposed so we set our own */ +#define MAX_INPUT_LENGTH 8000000 + +static char buffer[MAX_INPUT_LENGTH + 2]; + +int test(char *URL) +{ + const struct curl_easyoption *o; + CURL *easy; + int error = 0; + (void)URL; + + easy = curl_easy_init(); + if(!easy) + return 1; + + /* make it a zero terminated C string with just As */ + memset(buffer, 'A', MAX_INPUT_LENGTH + 1); + buffer[MAX_INPUT_LENGTH + 1] = 0; + + printf("string length: %d\n", (int)strlen(buffer)); + + for(o = curl_easy_option_next(NULL); + o; + o = curl_easy_option_next(o)) { + if(o->type == CURLOT_STRING) { + CURLcode result; + /* + * Whitelist string options that are safe for abuse + */ + switch(o->id) { + case CURLOPT_PROXY_TLSAUTH_TYPE: + case CURLOPT_TLSAUTH_TYPE: + continue; + default: + /* check this */ + break; + } + + /* This is a string. Make sure that passing in a string longer + CURL_MAX_INPUT_LENGTH returns an error */ + result = curl_easy_setopt(easy, o->id, buffer); + switch(result) { + case CURLE_BAD_FUNCTION_ARGUMENT: /* the most normal */ + case CURLE_UNKNOWN_OPTION: /* left out from the build */ + case CURLE_NOT_BUILT_IN: /* not supported */ + break; + default: + /* all other return codes are unexpected */ + fprintf(stderr, "curl_easy_setopt(%s...) returned %d\n", + o->name, (int)result); + error++; + break; + } + } + } + curl_easy_cleanup(easy); + return error; +} diff --git a/tests/libtest/mk-lib1521.pl b/tests/libtest/mk-lib1521.pl index f4ef19fe7..e71fe1e51 100755 --- a/tests/libtest/mk-lib1521.pl +++ b/tests/libtest/mk-lib1521.pl @@ -184,13 +184,15 @@ while(<STDIN>) { print "${pref} \"string\");\n$check"; print "${pref} NULL);\n$check"; } - elsif($type eq "CURLOPTTYPE_LONG") { + elsif(($type eq "CURLOPTTYPE_LONG") || + ($type eq "CURLOPTTYPE_VALUES")) { print "${pref} 0L);\n$check"; print "${pref} 22L);\n$check"; print "${pref} LO);\n$check"; print "${pref} HI);\n$check"; } - elsif($type eq "CURLOPTTYPE_OBJECTPOINT") { + elsif(($type eq "CURLOPTTYPE_OBJECTPOINT") || + ($type eq "CURLOPTTYPE_CBPOINT")) { if($name =~ /DEPENDS/) { print "${pref} dep);\n$check"; } @@ -244,8 +246,8 @@ while(<STDIN>) { print "${pref} &blob);\n$check"; } else { - print STDERR "\n---- $type\n"; - exit; # exit to make this noticed! + print STDERR "\nUnknown type: $type\n"; + exit 22; # exit to make this noticed! } } elsif($_ =~ /^ CURLINFO_NONE/) { diff --git a/tests/symbol-scan.pl b/tests/symbol-scan.pl index 7905ee772..2b2d6278b 100755 --- a/tests/symbol-scan.pl +++ b/tests/symbol-scan.pl @@ -176,7 +176,7 @@ if($summary) { } if($misses) { - exit 2; # there are stuff to attend to! + exit 0; # there are stuff to attend to! } else { print "OK\n"; |