mirror of
https://github.com/curl/curl.git
synced 2026-08-24 17:53:33 +03:00
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
This commit is contained in:
parent
9ee5701f12
commit
6ebe63fac2
22 changed files with 1019 additions and 58 deletions
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -27,5 +27,4 @@ Verify that symbols-in-versions and headers are in sync
|
|||
OK
|
||||
</stdout>
|
||||
</verify>
|
||||
|
||||
</testcase>
|
||||
|
|
|
|||
31
tests/data/test1911
Normal file
31
tests/data/test1911
Normal file
|
|
@ -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>
|
||||
|
|
@ -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
|
||||
|
|
|
|||
87
tests/libtest/lib1911.c
Normal file
87
tests/libtest/lib1911.c
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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/) {
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue