mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 23:54:35 +00:00
Update libcurl
This commit is contained in:
parent
20eb0a911a
commit
01a719ee58
3439 changed files with 529259 additions and 41492 deletions
71
Engine/lib/curl/tests/unit/CMakeLists.txt
Normal file
71
Engine/lib/curl/tests/unit/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) 1998 - 2022, 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.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.
|
||||
#
|
||||
# SPDX-License-Identifier: curl
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
# TODO build a special libcurlu library for unittests.
|
||||
return()
|
||||
|
||||
set(UT_SRC
|
||||
unit1300.c
|
||||
unit1301.c
|
||||
unit1302.c
|
||||
unit1303.c
|
||||
unit1304.c
|
||||
unit1305.c
|
||||
unit1307.c
|
||||
unit1308.c
|
||||
unit1309.c
|
||||
unit1330.c
|
||||
# Broken link on Linux
|
||||
# unit1394.c
|
||||
unit1395.c
|
||||
unit1396.c
|
||||
unit1397.c
|
||||
unit1398.c
|
||||
unit1600.c
|
||||
unit1601.c
|
||||
unit1603.c
|
||||
# Broken link on Linux
|
||||
# unit1604.c
|
||||
unit1620.c
|
||||
unit1655.c
|
||||
)
|
||||
|
||||
set(UT_COMMON_FILES ../libtest/first.c ../libtest/test.h curlcheck.h)
|
||||
include_directories(
|
||||
${CURL_SOURCE_DIR}/lib # To be able to reach "curl_setup_once.h"
|
||||
${CURL_SOURCE_DIR}/tests/libtest
|
||||
${CURL_SOURCE_DIR}/src
|
||||
${CURL_BINARY_DIR}/lib # To be able to reach "curl_config.h"
|
||||
${CURL_BINARY_DIR}/include # To be able to reach "curl/curl.h"
|
||||
)
|
||||
|
||||
foreach(_testfile ${UT_SRC})
|
||||
|
||||
get_filename_component(_testname ${_testfile} NAME_WE)
|
||||
add_executable(${_testname} EXCLUDE_FROM_ALL ${_testfile} ${UT_COMMON_FILES})
|
||||
#add_dependencies(testdeps ${_testname})
|
||||
target_link_libraries(${_testname} libcurl ${CURL_LIBS})
|
||||
set_target_properties(${_testname}
|
||||
PROPERTIES COMPILE_DEFINITIONS "UNITTESTS")
|
||||
endforeach()
|
||||
69
Engine/lib/curl/tests/unit/Makefile.am
Normal file
69
Engine/lib/curl/tests/unit/Makefile.am
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) 1998 - 2022, 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.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.
|
||||
#
|
||||
# SPDX-License-Identifier: curl
|
||||
#
|
||||
###########################################################################
|
||||
AUTOMAKE_OPTIONS = foreign nostdinc
|
||||
|
||||
# Specify our include paths here, and do it relative to $(top_srcdir) and
|
||||
# $(top_builddir), to ensure that these paths which belong to the library
|
||||
# being currently built and tested are searched before the library which
|
||||
# might possibly already be installed in the system.
|
||||
#
|
||||
# $(top_srcdir)/include is for libcurl's external include files
|
||||
# $(top_builddir)/lib is for libcurl's generated lib/curl_config.h file
|
||||
# $(top_srcdir)/lib for libcurl's lib/curl_setup.h and other "borrowed" files
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include \
|
||||
-I$(top_builddir)/lib \
|
||||
-I$(top_srcdir)/lib \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/tests/libtest
|
||||
|
||||
EXTRA_DIST = Makefile.inc CMakeLists.txt README.md
|
||||
|
||||
CFLAGS += @CURL_CFLAG_EXTRAS@
|
||||
|
||||
# Prevent LIBS from being used for all link targets
|
||||
LIBS = $(BLANK_AT_MAKETIME)
|
||||
|
||||
LDADD = $(top_builddir)/src/libcurltool.la \
|
||||
$(top_builddir)/lib/libcurlu.la \
|
||||
@LDFLAGS@ @LIBCURL_LIBS@ @NSS_LIBS@
|
||||
|
||||
AM_CPPFLAGS += -DCURL_STATICLIB -DUNITTESTS
|
||||
|
||||
# Makefile.inc provides neat definitions
|
||||
include Makefile.inc
|
||||
|
||||
CHECKSRC = $(CS_$(V))
|
||||
CS_0 = @echo " RUN " $@;
|
||||
CS_1 =
|
||||
CS_ = $(CS_0)
|
||||
|
||||
checksrc:
|
||||
$(CHECKSRC)@PERL@ $(top_srcdir)/scripts/checksrc.pl $(srcdir)/*.[ch]
|
||||
|
||||
if BUILD_UNITTESTS
|
||||
noinst_PROGRAMS = $(UNITPROGS)
|
||||
else
|
||||
noinst_PROGRAMS =
|
||||
endif
|
||||
2852
Engine/lib/curl/tests/unit/Makefile.in
Normal file
2852
Engine/lib/curl/tests/unit/Makefile.in
Normal file
File diff suppressed because it is too large
Load diff
164
Engine/lib/curl/tests/unit/Makefile.inc
Normal file
164
Engine/lib/curl/tests/unit/Makefile.inc
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) 1998 - 2022, 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.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.
|
||||
#
|
||||
# SPDX-License-Identifier: curl
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
# these files are used in every single unit test program
|
||||
|
||||
UNITFILES = curlcheck.h \
|
||||
../libtest/test.h \
|
||||
../libtest/first.c
|
||||
|
||||
# These are all unit test programs
|
||||
UNITPROGS = unit1300 unit1301 unit1302 unit1303 unit1304 unit1305 unit1307 \
|
||||
unit1308 unit1309 unit1323 \
|
||||
unit1330 unit1394 unit1395 unit1396 unit1397 unit1398 \
|
||||
unit1399 \
|
||||
unit1600 unit1601 unit1602 unit1603 unit1604 unit1605 unit1606 unit1607 \
|
||||
unit1608 unit1609 unit1610 unit1611 unit1612 \
|
||||
unit1620 unit1621 \
|
||||
unit1650 unit1651 unit1652 unit1653 unit1654 unit1655 \
|
||||
unit1660 unit1661
|
||||
|
||||
unit1300_SOURCES = unit1300.c $(UNITFILES)
|
||||
unit1300_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1301_SOURCES = unit1301.c $(UNITFILES)
|
||||
unit1301_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1302_SOURCES = unit1302.c $(UNITFILES)
|
||||
unit1302_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1303_SOURCES = unit1303.c $(UNITFILES)
|
||||
unit1303_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1304_SOURCES = unit1304.c $(UNITFILES)
|
||||
unit1304_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1305_SOURCES = unit1305.c $(UNITFILES)
|
||||
unit1305_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1307_SOURCES = unit1307.c $(UNITFILES)
|
||||
unit1307_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1308_SOURCES = unit1308.c $(UNITFILES)
|
||||
unit1308_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1309_SOURCES = unit1309.c $(UNITFILES)
|
||||
unit1309_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1323_SOURCES = unit1323.c $(UNITFILES)
|
||||
unit1323_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1330_SOURCES = unit1330.c $(UNITFILES)
|
||||
unit1330_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1394_SOURCES = unit1394.c $(UNITFILES)
|
||||
unit1394_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
unit1394_LDADD = $(top_builddir)/lib/libcurl.la @LIBCURL_LIBS@
|
||||
unit1394_LDFLAGS = $(top_builddir)/src/libcurltool.la
|
||||
unit1394_LIBS =
|
||||
|
||||
unit1395_SOURCES = unit1395.c $(UNITFILES)
|
||||
unit1395_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1396_SOURCES = unit1396.c $(UNITFILES)
|
||||
unit1396_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1397_SOURCES = unit1397.c $(UNITFILES)
|
||||
unit1397_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1398_SOURCES = unit1398.c $(UNITFILES)
|
||||
unit1398_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1399_SOURCES = unit1399.c $(UNITFILES)
|
||||
unit1399_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1600_SOURCES = unit1600.c $(UNITFILES)
|
||||
unit1600_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1601_SOURCES = unit1601.c $(UNITFILES)
|
||||
unit1601_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1602_SOURCES = unit1602.c $(UNITFILES)
|
||||
unit1602_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1603_SOURCES = unit1603.c $(UNITFILES)
|
||||
unit1603_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1604_SOURCES = unit1604.c $(UNITFILES)
|
||||
unit1604_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1605_SOURCES = unit1605.c $(UNITFILES)
|
||||
unit1605_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1606_SOURCES = unit1606.c $(UNITFILES)
|
||||
unit1606_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1607_SOURCES = unit1607.c $(UNITFILES)
|
||||
unit1607_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1608_SOURCES = unit1608.c $(UNITFILES)
|
||||
unit1608_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1609_SOURCES = unit1609.c $(UNITFILES)
|
||||
unit1609_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1610_SOURCES = unit1610.c $(UNITFILES)
|
||||
unit1610_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1611_SOURCES = unit1611.c $(UNITFILES)
|
||||
unit1611_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1612_SOURCES = unit1612.c $(UNITFILES)
|
||||
unit1612_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1620_SOURCES = unit1620.c $(UNITFILES)
|
||||
unit1620_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1621_SOURCES = unit1621.c $(UNITFILES)
|
||||
unit1621_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
unit1621_LDADD = $(top_builddir)/src/libcurltool.la $(top_builddir)/lib/libcurl.la @NSS_LIBS@
|
||||
|
||||
unit1650_SOURCES = unit1650.c $(UNITFILES)
|
||||
unit1650_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1651_SOURCES = unit1651.c $(UNITFILES)
|
||||
unit1651_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1652_SOURCES = unit1652.c $(UNITFILES)
|
||||
unit1652_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1653_SOURCES = unit1653.c $(UNITFILES)
|
||||
unit1653_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1654_SOURCES = unit1654.c $(UNITFILES)
|
||||
unit1654_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1655_SOURCES = unit1655.c $(UNITFILES)
|
||||
unit1655_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1660_SOURCES = unit1660.c $(UNITFILES)
|
||||
unit1660_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
unit1661_SOURCES = unit1661.c $(UNITFILES)
|
||||
unit1661_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
72
Engine/lib/curl/tests/unit/README.md
Normal file
72
Engine/lib/curl/tests/unit/README.md
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<!--
|
||||
Copyright (C) 1998 - 2022 Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
|
||||
SPDX-License-Identifier: curl
|
||||
-->
|
||||
|
||||
# Unit tests
|
||||
|
||||
The goal is to add tests for *all* functions in libcurl. If functions are too
|
||||
big and complicated, we should split them into smaller and testable ones.
|
||||
|
||||
## Build Unit Tests
|
||||
|
||||
`./configure --enable-debug` is required for the unit tests to build. To
|
||||
enable unit tests, there will be a separate static libcurl built that will be
|
||||
used exclusively for linking unit test programs. Just build everything as
|
||||
normal, and then you can run the unit test cases as well.
|
||||
|
||||
## Run Unit Tests
|
||||
|
||||
Unit tests are run as part of the regular test suite. If you have built
|
||||
everything to run unit tests, to can do 'make test' at the root level. Or you
|
||||
can `cd tests` and `make` and then invoke individual unit tests with
|
||||
`./runtests.pl NNNN` where `NNNN` is the specific test number.
|
||||
|
||||
## Debug Unit Tests
|
||||
|
||||
If a specific test fails you will get told. The test case then has output left
|
||||
in the log/ subdirectory, but most importantly you can re-run the test again
|
||||
using gdb by doing `./runtests.pl -g NNNN`. That is, add a `-g` to make it
|
||||
start up gdb and run the same case using that.
|
||||
|
||||
## Write Unit Tests
|
||||
|
||||
We put tests that focus on an area or a specific function into a single C
|
||||
source file. The source file should be named 'unitNNNN.c' where NNNN is a
|
||||
previously unused number.
|
||||
|
||||
Add your test to `tests/unit/Makefile.inc` (if it is a unit test). Add your
|
||||
test data file name to `tests/data/Makefile.inc`
|
||||
|
||||
You also need a separate file called `tests/data/testNNNN` (using the same
|
||||
number) that describes your test case. See the test1300 file for inspiration
|
||||
and the `tests/FILEFORMAT.md` documentation.
|
||||
|
||||
For the actual C file, here's a very simple example:
|
||||
~~~c
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "a libcurl header.h" /* from the lib dir */
|
||||
|
||||
static CURLcode unit_setup( void )
|
||||
{
|
||||
/* whatever you want done first */
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop( void )
|
||||
{
|
||||
/* done before shutting down and exiting */
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
/* here you start doing things and checking that the results are good */
|
||||
|
||||
fail_unless( size == 0 , "initial size should be zero" );
|
||||
fail_if( head == NULL , "head should not be initiated to NULL" );
|
||||
|
||||
/* you end the test code like this: */
|
||||
|
||||
UNITTEST_STOP
|
||||
113
Engine/lib/curl/tests/unit/curlcheck.h
Normal file
113
Engine/lib/curl/tests/unit/curlcheck.h
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
/* The fail macros mark the current test step as failed, and continue */
|
||||
#define fail_if(expr, msg) \
|
||||
do { \
|
||||
if(expr) { \
|
||||
fprintf(stderr, "%s:%d Assertion '%s' met: %s\n", \
|
||||
__FILE__, __LINE__, #expr, msg); \
|
||||
unitfail++; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define fail_unless(expr, msg) \
|
||||
do { \
|
||||
if(!(expr)) { \
|
||||
fprintf(stderr, "%s:%d Assertion '%s' failed: %s\n", \
|
||||
__FILE__, __LINE__, #expr, msg); \
|
||||
unitfail++; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define verify_memory(dynamic, check, len) \
|
||||
do { \
|
||||
if(dynamic && memcmp(dynamic, check, len)) { \
|
||||
fprintf(stderr, "%s:%d Memory buffer mismatch size %d. '%s' is not\n", \
|
||||
__FILE__, __LINE__, len, \
|
||||
hexdump((const unsigned char *)check, len)); \
|
||||
fprintf(stderr, "%s:%d the same as '%s'\n", __FILE__, __LINE__, \
|
||||
hexdump((const unsigned char *)dynamic, len)); \
|
||||
unitfail++; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* fail() is for when the test case figured out by itself that a check
|
||||
proved a failure */
|
||||
#define fail(msg) do { \
|
||||
fprintf(stderr, "%s:%d test failed: '%s'\n", \
|
||||
__FILE__, __LINE__, msg); \
|
||||
unitfail++; \
|
||||
} while(0)
|
||||
|
||||
|
||||
/* The abort macros mark the current test step as failed, and exit the test */
|
||||
#define abort_if(expr, msg) \
|
||||
do { \
|
||||
if(expr) { \
|
||||
fprintf(stderr, "%s:%d Abort assertion '%s' met: %s\n", \
|
||||
__FILE__, __LINE__, #expr, msg); \
|
||||
unitfail++; \
|
||||
goto unit_test_abort; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define abort_unless(expr, msg) \
|
||||
do { \
|
||||
if(!(expr)) { \
|
||||
fprintf(stderr, "%s:%d Abort assertion '%s' failed: %s\n", \
|
||||
__FILE__, __LINE__, #expr, msg); \
|
||||
unitfail++; \
|
||||
goto unit_test_abort; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define abort_test(msg) \
|
||||
do { \
|
||||
fprintf(stderr, "%s:%d test aborted: '%s'\n", \
|
||||
__FILE__, __LINE__, msg); \
|
||||
unitfail++; \
|
||||
goto unit_test_abort; \
|
||||
} while(0)
|
||||
|
||||
|
||||
extern int unitfail;
|
||||
|
||||
#define UNITTEST_START \
|
||||
int test(char *arg) \
|
||||
{ \
|
||||
(void)arg; \
|
||||
if(unit_setup()) { \
|
||||
fail("unit_setup() failure"); \
|
||||
} \
|
||||
else {
|
||||
|
||||
#define UNITTEST_STOP \
|
||||
goto unit_test_abort; /* avoid warning */ \
|
||||
unit_test_abort: \
|
||||
unit_stop(); \
|
||||
} \
|
||||
return unitfail; \
|
||||
}
|
||||
223
Engine/lib/curl/tests/unit/unit1300.c
Normal file
223
Engine/lib/curl/tests/unit/unit1300.c
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "llist.h"
|
||||
|
||||
static struct Curl_llist llist;
|
||||
|
||||
static struct Curl_llist llist_destination;
|
||||
|
||||
static void test_Curl_llist_dtor(void *key, void *value)
|
||||
{
|
||||
/* used by the llist API, does nothing here */
|
||||
(void)key;
|
||||
(void)value;
|
||||
}
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
Curl_llist_init(&llist, test_Curl_llist_dtor);
|
||||
Curl_llist_init(&llist_destination, test_Curl_llist_dtor);
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
int unusedData_case1 = 1;
|
||||
int unusedData_case2 = 2;
|
||||
int unusedData_case3 = 3;
|
||||
struct Curl_llist_element case1_list;
|
||||
struct Curl_llist_element case2_list;
|
||||
struct Curl_llist_element case3_list;
|
||||
struct Curl_llist_element case4_list;
|
||||
struct Curl_llist_element *head;
|
||||
struct Curl_llist_element *element_next;
|
||||
struct Curl_llist_element *element_prev;
|
||||
struct Curl_llist_element *to_remove;
|
||||
size_t llist_size = Curl_llist_count(&llist);
|
||||
|
||||
/**
|
||||
* testing llist_init
|
||||
* case 1:
|
||||
* list initiation
|
||||
* @assumptions:
|
||||
* 1: list size will be 0
|
||||
* 2: list head will be NULL
|
||||
* 3: list tail will be NULL
|
||||
* 4: list dtor will be NULL
|
||||
*/
|
||||
|
||||
fail_unless(llist.size == 0, "list initial size should be zero");
|
||||
fail_unless(llist.head == NULL, "list head should initiate to NULL");
|
||||
fail_unless(llist.tail == NULL, "list tail should intiate to NULL");
|
||||
fail_unless(llist.dtor == test_Curl_llist_dtor,
|
||||
"list dtor should initiate to test_Curl_llist_dtor");
|
||||
|
||||
/**
|
||||
* testing Curl_llist_insert_next
|
||||
* case 1:
|
||||
* list is empty
|
||||
* @assumptions:
|
||||
* 1: list size will be 1
|
||||
* 2: list head will hold the data "unusedData_case1"
|
||||
* 3: list tail will be the same as list head
|
||||
*/
|
||||
|
||||
Curl_llist_insert_next(&llist, llist.head, &unusedData_case1, &case1_list);
|
||||
|
||||
fail_unless(Curl_llist_count(&llist) == 1,
|
||||
"List size should be 1 after adding a new element");
|
||||
/*test that the list head data holds my unusedData */
|
||||
fail_unless(llist.head->ptr == &unusedData_case1,
|
||||
"head ptr should be first entry");
|
||||
/*same goes for the list tail */
|
||||
fail_unless(llist.tail == llist.head,
|
||||
"tail and head should be the same");
|
||||
|
||||
/**
|
||||
* testing Curl_llist_insert_next
|
||||
* case 2:
|
||||
* list has 1 element, adding one element after the head
|
||||
* @assumptions:
|
||||
* 1: the element next to head should be our newly created element
|
||||
* 2: the list tail should be our newly created element
|
||||
*/
|
||||
|
||||
Curl_llist_insert_next(&llist, llist.head,
|
||||
&unusedData_case3, &case3_list);
|
||||
fail_unless(llist.head->next->ptr == &unusedData_case3,
|
||||
"the node next to head is not getting set correctly");
|
||||
fail_unless(llist.tail->ptr == &unusedData_case3,
|
||||
"the list tail is not getting set correctly");
|
||||
|
||||
/**
|
||||
* testing Curl_llist_insert_next
|
||||
* case 3:
|
||||
* list has >1 element, adding one element after "NULL"
|
||||
* @assumptions:
|
||||
* 1: the element next to head should be our newly created element
|
||||
* 2: the list tail should different from newly created element
|
||||
*/
|
||||
|
||||
Curl_llist_insert_next(&llist, llist.head,
|
||||
&unusedData_case2, &case2_list);
|
||||
fail_unless(llist.head->next->ptr == &unusedData_case2,
|
||||
"the node next to head is not getting set correctly");
|
||||
/* better safe than sorry, check that the tail isn't corrupted */
|
||||
fail_unless(llist.tail->ptr != &unusedData_case2,
|
||||
"the list tail is not getting set correctly");
|
||||
|
||||
/* unit tests for Curl_llist_remove */
|
||||
|
||||
/**
|
||||
* case 1:
|
||||
* list has >1 element, removing head
|
||||
* @assumptions:
|
||||
* 1: list size will be decremented by one
|
||||
* 2: head will be the head->next
|
||||
* 3: "new" head's previous will be NULL
|
||||
*/
|
||||
|
||||
head = llist.head;
|
||||
abort_unless(head, "llist.head is NULL");
|
||||
element_next = head->next;
|
||||
llist_size = Curl_llist_count(&llist);
|
||||
|
||||
Curl_llist_remove(&llist, llist.head, NULL);
|
||||
|
||||
fail_unless(Curl_llist_count(&llist) == (llist_size-1),
|
||||
"llist size not decremented as expected");
|
||||
fail_unless(llist.head == element_next,
|
||||
"llist new head not modified properly");
|
||||
abort_unless(llist.head, "llist.head is NULL");
|
||||
fail_unless(llist.head->prev == NULL,
|
||||
"new head previous not set to null");
|
||||
|
||||
/**
|
||||
* case 2:
|
||||
* removing non head element, with list having >=2 elements
|
||||
* @setup:
|
||||
* 1: insert another element to the list to make element >=2
|
||||
* @assumptions:
|
||||
* 1: list size will be decremented by one ; tested
|
||||
* 2: element->previous->next will be element->next
|
||||
* 3: element->next->previous will be element->previous
|
||||
*/
|
||||
Curl_llist_insert_next(&llist, llist.head, &unusedData_case3,
|
||||
&case4_list);
|
||||
llist_size = Curl_llist_count(&llist);
|
||||
fail_unless(llist_size == 3, "should be 3 list members");
|
||||
|
||||
to_remove = llist.head->next;
|
||||
abort_unless(to_remove, "to_remove is NULL");
|
||||
element_next = to_remove->next;
|
||||
element_prev = to_remove->prev;
|
||||
Curl_llist_remove(&llist, to_remove, NULL);
|
||||
fail_unless(element_prev->next == element_next,
|
||||
"element previous->next is not being adjusted");
|
||||
abort_unless(element_next, "element_next is NULL");
|
||||
fail_unless(element_next->prev == element_prev,
|
||||
"element next->previous is not being adjusted");
|
||||
|
||||
/**
|
||||
* case 3:
|
||||
* removing the tail with list having >=1 element
|
||||
* @assumptions
|
||||
* 1: list size will be decremented by one ;tested
|
||||
* 2: element->previous->next will be element->next ;tested
|
||||
* 3: element->next->previous will be element->previous ;tested
|
||||
* 4: list->tail will be tail->previous
|
||||
*/
|
||||
|
||||
to_remove = llist.tail;
|
||||
element_prev = to_remove->prev;
|
||||
Curl_llist_remove(&llist, to_remove, NULL);
|
||||
fail_unless(llist.tail == element_prev,
|
||||
"llist tail is not being adjusted when removing tail");
|
||||
|
||||
/**
|
||||
* case 4:
|
||||
* removing head with list having 1 element
|
||||
* @assumptions:
|
||||
* 1: list size will be decremented by one ;tested
|
||||
* 2: list head will be null
|
||||
* 3: list tail will be null
|
||||
*/
|
||||
|
||||
to_remove = llist.head;
|
||||
Curl_llist_remove(&llist, to_remove, NULL);
|
||||
fail_unless(llist.head == NULL,
|
||||
"llist head is not NULL while the llist is empty");
|
||||
fail_unless(llist.tail == NULL,
|
||||
"llist tail is not NULL while the llist is empty");
|
||||
|
||||
Curl_llist_destroy(&llist, NULL);
|
||||
Curl_llist_destroy(&llist_destination, NULL);
|
||||
}
|
||||
UNITTEST_STOP
|
||||
56
Engine/lib/curl/tests/unit/unit1301.c
Normal file
56
Engine/lib/curl/tests/unit/unit1301.c
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "strcase.h"
|
||||
|
||||
static CURLcode unit_setup(void) {return CURLE_OK;}
|
||||
static void unit_stop(void) {}
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
int rc;
|
||||
|
||||
rc = curl_strequal("iii", "III");
|
||||
fail_unless(rc != 0, "return code should be non-zero");
|
||||
|
||||
rc = curl_strequal("iiia", "III");
|
||||
fail_unless(rc == 0, "return code should be zero");
|
||||
|
||||
rc = curl_strequal("iii", "IIIa");
|
||||
fail_unless(rc == 0, "return code should be zero");
|
||||
|
||||
rc = curl_strequal("iiiA", "IIIa");
|
||||
fail_unless(rc != 0, "return code should be non-zero");
|
||||
|
||||
rc = curl_strnequal("iii", "III", 3);
|
||||
fail_unless(rc != 0, "return code should be non-zero");
|
||||
|
||||
rc = curl_strnequal("iiiABC", "IIIcba", 3);
|
||||
fail_unless(rc != 0, "return code should be non-zero");
|
||||
|
||||
rc = curl_strnequal("ii", "II", 3);
|
||||
fail_unless(rc != 0, "return code should be non-zero");
|
||||
|
||||
UNITTEST_STOP
|
||||
181
Engine/lib/curl/tests/unit/unit1302.c
Normal file
181
Engine/lib/curl/tests/unit/unit1302.c
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "urldata.h"
|
||||
#include "url.h" /* for Curl_safefree */
|
||||
#include "curl_base64.h"
|
||||
#include "memdebug.h" /* LAST include file */
|
||||
|
||||
static struct Curl_easy *data;
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
data = curl_easy_init();
|
||||
if(!data) {
|
||||
curl_global_cleanup();
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
curl_easy_cleanup(data);
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
char *output;
|
||||
unsigned char *decoded;
|
||||
size_t size = 0;
|
||||
unsigned char anychar = 'x';
|
||||
CURLcode rc;
|
||||
|
||||
rc = Curl_base64_encode("i", 1, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 4, "size should be 4");
|
||||
verify_memory(output, "aQ==", 4);
|
||||
Curl_safefree(output);
|
||||
|
||||
rc = Curl_base64_encode("ii", 2, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 4, "size should be 4");
|
||||
verify_memory(output, "aWk=", 4);
|
||||
Curl_safefree(output);
|
||||
|
||||
rc = Curl_base64_encode("iii", 3, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 4, "size should be 4");
|
||||
verify_memory(output, "aWlp", 4);
|
||||
Curl_safefree(output);
|
||||
|
||||
rc = Curl_base64_encode("iiii", 4, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 8, "size should be 8");
|
||||
verify_memory(output, "aWlpaQ==", 8);
|
||||
Curl_safefree(output);
|
||||
|
||||
rc = Curl_base64_encode("\xff\x01\xfe\x02", 4, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 8, "size should be 8");
|
||||
verify_memory(output, "/wH+Ag==", 8);
|
||||
Curl_safefree(output);
|
||||
|
||||
rc = Curl_base64url_encode("\xff\x01\xfe\x02", 4, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 6, "size should be 6");
|
||||
verify_memory(output, "_wH-Ag", 6);
|
||||
Curl_safefree(output);
|
||||
|
||||
rc = Curl_base64url_encode("iiii", 4, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 6, "size should be 6");
|
||||
verify_memory(output, "aWlpaQ", 6);
|
||||
Curl_safefree(output);
|
||||
|
||||
/* 0 length makes it do strlen() */
|
||||
rc = Curl_base64_encode("iiii", 0, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 8, "size should be 8");
|
||||
verify_memory(output, "aWlpaQ==", 8);
|
||||
Curl_safefree(output);
|
||||
|
||||
rc = Curl_base64_encode("", 0, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 0, "size should be 0");
|
||||
fail_unless(output && !output[0], "output should be a zero-length string");
|
||||
Curl_safefree(output);
|
||||
|
||||
rc = Curl_base64url_encode("", 0, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 0, "size should be 0");
|
||||
fail_unless(output && !output[0], "output should be a zero-length string");
|
||||
Curl_safefree(output);
|
||||
|
||||
rc = Curl_base64_decode("aWlpaQ==", &decoded, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 4, "size should be 4");
|
||||
verify_memory(decoded, "iiii", 4);
|
||||
Curl_safefree(decoded);
|
||||
|
||||
rc = Curl_base64_decode("aWlp", &decoded, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 3, "size should be 3");
|
||||
verify_memory(decoded, "iii", 3);
|
||||
Curl_safefree(decoded);
|
||||
|
||||
rc = Curl_base64_decode("aWk=", &decoded, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 2, "size should be 2");
|
||||
verify_memory(decoded, "ii", 2);
|
||||
Curl_safefree(decoded);
|
||||
|
||||
rc = Curl_base64_decode("aQ==", &decoded, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 1, "size should be 1");
|
||||
verify_memory(decoded, "i", 2);
|
||||
Curl_safefree(decoded);
|
||||
|
||||
/* This is illegal input as the data is too short */
|
||||
size = 1; /* not zero */
|
||||
decoded = &anychar; /* not NULL */
|
||||
rc = Curl_base64_decode("aQ", &decoded, &size);
|
||||
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");
|
||||
|
||||
/* This is illegal input as it contains three padding characters */
|
||||
size = 1; /* not zero */
|
||||
decoded = &anychar; /* not NULL */
|
||||
rc = Curl_base64_decode("a===", &decoded, &size);
|
||||
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");
|
||||
|
||||
/* This is illegal input as it contains a padding character mid input */
|
||||
size = 1; /* not zero */
|
||||
decoded = &anychar; /* not NULL */
|
||||
rc = Curl_base64_decode("a=Q=", &decoded, &size);
|
||||
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");
|
||||
|
||||
/* 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_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
|
||||
153
Engine/lib/curl/tests/unit/unit1303.c
Normal file
153
Engine/lib/curl/tests/unit/unit1303.c
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "urldata.h"
|
||||
#include "connect.h"
|
||||
#include "memdebug.h" /* LAST include file */
|
||||
|
||||
static struct Curl_easy *data;
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
data = curl_easy_init();
|
||||
if(!data) {
|
||||
curl_global_cleanup();
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
curl_easy_cleanup(data);
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
/* BASE is just a define to make us fool around with decently large number so
|
||||
that we aren't zero-based */
|
||||
#define BASE 1000000
|
||||
|
||||
/* macro to set the pretended current time */
|
||||
#define NOW(x,y) now.tv_sec = x; now.tv_usec = y
|
||||
/* macro to set the millisecond based timeouts to use */
|
||||
#define TIMEOUTS(x,y) data->set.timeout = x; data->set.connecttimeout = y
|
||||
|
||||
/*
|
||||
* To test:
|
||||
*
|
||||
* 00/10/01/11 timeouts set
|
||||
* 0/1 during connect
|
||||
* T various values on the timeouts
|
||||
* N various values of now
|
||||
*/
|
||||
|
||||
struct timetest {
|
||||
int now_s;
|
||||
int now_us;
|
||||
int timeout_ms;
|
||||
int connecttimeout_ms;
|
||||
bool connecting;
|
||||
timediff_t result;
|
||||
const char *comment;
|
||||
};
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
struct curltime now;
|
||||
unsigned int i;
|
||||
|
||||
const struct timetest run[] = {
|
||||
/* both timeouts set, not connecting */
|
||||
{BASE + 4, 0, 10000, 8000, FALSE, 6000, "6 seconds should be left"},
|
||||
{BASE + 4, 990000, 10000, 8000, FALSE, 5010, "5010 ms should be left"},
|
||||
{BASE + 10, 0, 10000, 8000, FALSE, -1, "timeout is -1, expired"},
|
||||
{BASE + 12, 0, 10000, 8000, FALSE, -2000, "-2000, overdue 2 seconds"},
|
||||
|
||||
/* both timeouts set, connecting */
|
||||
{BASE + 4, 0, 10000, 8000, TRUE, 4000, "4 seconds should be left"},
|
||||
{BASE + 4, 990000, 10000, 8000, TRUE, 3010, "3010 ms should be left"},
|
||||
{BASE + 8, 0, 10000, 8000, TRUE, -1, "timeout is -1, expired"},
|
||||
{BASE + 10, 0, 10000, 8000, TRUE, -2000, "-2000, overdue 2 seconds"},
|
||||
|
||||
/* no connect timeout set, not connecting */
|
||||
{BASE + 4, 0, 10000, 0, FALSE, 6000, "6 seconds should be left"},
|
||||
{BASE + 4, 990000, 10000, 0, FALSE, 5010, "5010 ms should be left"},
|
||||
{BASE + 10, 0, 10000, 0, FALSE, -1, "timeout is -1, expired"},
|
||||
{BASE + 12, 0, 10000, 0, FALSE, -2000, "-2000, overdue 2 seconds"},
|
||||
|
||||
/* no connect timeout set, connecting */
|
||||
{BASE + 4, 0, 10000, 0, TRUE, 6000, "6 seconds should be left"},
|
||||
{BASE + 4, 990000, 10000, 0, TRUE, 5010, "5010 ms should be left"},
|
||||
{BASE + 10, 0, 10000, 0, TRUE, -1, "timeout is -1, expired"},
|
||||
{BASE + 12, 0, 10000, 0, TRUE, -2000, "-2000, overdue 2 seconds"},
|
||||
|
||||
/* only connect timeout set, not connecting */
|
||||
{BASE + 4, 0, 0, 10000, FALSE, 0, "no timeout active"},
|
||||
{BASE + 4, 990000, 0, 10000, FALSE, 0, "no timeout active"},
|
||||
{BASE + 10, 0, 0, 10000, FALSE, 0, "no timeout active"},
|
||||
{BASE + 12, 0, 0, 10000, FALSE, 0, "no timeout active"},
|
||||
|
||||
/* only connect timeout set, connecting */
|
||||
{BASE + 4, 0, 0, 10000, TRUE, 6000, "6 seconds should be left"},
|
||||
{BASE + 4, 990000, 0, 10000, TRUE, 5010, "5010 ms should be left"},
|
||||
{BASE + 10, 0, 0, 10000, TRUE, -1, "timeout is -1, expired"},
|
||||
{BASE + 12, 0, 0, 10000, TRUE, -2000, "-2000, overdue 2 seconds"},
|
||||
|
||||
/* no timeout set, not connecting */
|
||||
{BASE + 4, 0, 0, 0, FALSE, 0, "no timeout active"},
|
||||
{BASE + 4, 990000, 0, 0, FALSE, 0, "no timeout active"},
|
||||
{BASE + 10, 0, 0, 0, FALSE, 0, "no timeout active"},
|
||||
{BASE + 12, 0, 0, 0, FALSE, 0, "no timeout active"},
|
||||
|
||||
/* no timeout set, connecting */
|
||||
{BASE + 4, 0, 0, 0, TRUE, 296000, "no timeout active"},
|
||||
{BASE + 4, 990000, 0, 0, TRUE, 295010, "no timeout active"},
|
||||
{BASE + 10, 0, 0, 0, TRUE, 290000, "no timeout active"},
|
||||
{BASE + 12, 0, 0, 0, TRUE, 288000, "no timeout active"},
|
||||
|
||||
/* both timeouts set, connecting, connect timeout the longer one */
|
||||
{BASE + 4, 0, 10000, 12000, TRUE, 6000, "6 seconds should be left"},
|
||||
|
||||
};
|
||||
|
||||
/* this is the pretended start time of the transfer */
|
||||
data->progress.t_startsingle.tv_sec = BASE;
|
||||
data->progress.t_startsingle.tv_usec = 0;
|
||||
data->progress.t_startop.tv_sec = BASE;
|
||||
data->progress.t_startop.tv_usec = 0;
|
||||
|
||||
for(i = 0; i < sizeof(run)/sizeof(run[0]); i++) {
|
||||
timediff_t timeout;
|
||||
NOW(run[i].now_s, run[i].now_us);
|
||||
TIMEOUTS(run[i].timeout_ms, run[i].connecttimeout_ms);
|
||||
timeout = Curl_timeleft(data, &now, run[i].connecting);
|
||||
if(timeout != run[i].result)
|
||||
fail(run[i].comment);
|
||||
}
|
||||
}
|
||||
UNITTEST_STOP
|
||||
212
Engine/lib/curl/tests/unit/unit1304.c
Normal file
212
Engine/lib/curl/tests/unit/unit1304.c
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
#include "netrc.h"
|
||||
#include "memdebug.h" /* LAST include file */
|
||||
|
||||
static char *login;
|
||||
static char *password;
|
||||
static char filename[64];
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
password = strdup("");
|
||||
login = strdup("");
|
||||
if(!password || !login) {
|
||||
Curl_safefree(password);
|
||||
Curl_safefree(login);
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
Curl_safefree(password);
|
||||
Curl_safefree(login);
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
int result;
|
||||
bool login_changed;
|
||||
bool password_changed;
|
||||
|
||||
static const char * const filename1 = "log/netrc1304";
|
||||
memcpy(filename, filename1, strlen(filename1));
|
||||
|
||||
/*
|
||||
* Test a non existent host in our netrc file.
|
||||
*/
|
||||
result = Curl_parsenetrc("test.example.com", &login, &password,
|
||||
&login_changed, &password_changed, filename);
|
||||
fail_unless(result == 1, "Host not found should return 1");
|
||||
abort_unless(password != NULL, "returned NULL!");
|
||||
fail_unless(password[0] == 0, "password should not have been changed");
|
||||
abort_unless(login != NULL, "returned NULL!");
|
||||
fail_unless(login[0] == 0, "login should not have been changed");
|
||||
|
||||
/*
|
||||
* Test a non existent login in our netrc file.
|
||||
*/
|
||||
free(login);
|
||||
login = strdup("me");
|
||||
abort_unless(login != NULL, "returned NULL!");
|
||||
result = Curl_parsenetrc("example.com", &login, &password,
|
||||
&login_changed, &password_changed, filename);
|
||||
fail_unless(result == 0, "Host should have been found");
|
||||
abort_unless(password != NULL, "returned NULL!");
|
||||
fail_unless(password[0] == 0, "password should not have been changed");
|
||||
fail_unless(!password_changed, "password should not have been changed");
|
||||
abort_unless(login != NULL, "returned NULL!");
|
||||
fail_unless(strncmp(login, "me", 2) == 0,
|
||||
"login should not have been changed");
|
||||
fail_unless(!login_changed, "login should not have been changed");
|
||||
|
||||
/*
|
||||
* Test a non existent login and host in our netrc file.
|
||||
*/
|
||||
free(login);
|
||||
login = strdup("me");
|
||||
abort_unless(login != NULL, "returned NULL!");
|
||||
result = Curl_parsenetrc("test.example.com", &login, &password,
|
||||
&login_changed, &password_changed, filename);
|
||||
fail_unless(result == 1, "Host not found should return 1");
|
||||
abort_unless(password != NULL, "returned NULL!");
|
||||
fail_unless(password[0] == 0, "password should not have been changed");
|
||||
abort_unless(login != NULL, "returned NULL!");
|
||||
fail_unless(strncmp(login, "me", 2) == 0,
|
||||
"login should not have been changed");
|
||||
|
||||
/*
|
||||
* Test a non existent login (substring of an existing one) in our
|
||||
* netrc file.
|
||||
*/
|
||||
free(login);
|
||||
login = strdup("admi");
|
||||
abort_unless(login != NULL, "returned NULL!");
|
||||
result = Curl_parsenetrc("example.com", &login, &password,
|
||||
&login_changed, &password_changed, filename);
|
||||
fail_unless(result == 0, "Host should have been found");
|
||||
abort_unless(password != NULL, "returned NULL!");
|
||||
fail_unless(password[0] == 0, "password should not have been changed");
|
||||
fail_unless(!password_changed, "password should not have been changed");
|
||||
abort_unless(login != NULL, "returned NULL!");
|
||||
fail_unless(strncmp(login, "admi", 4) == 0,
|
||||
"login should not have been changed");
|
||||
fail_unless(!login_changed, "login should not have been changed");
|
||||
|
||||
/*
|
||||
* Test a non existent login (superstring of an existing one)
|
||||
* in our netrc file.
|
||||
*/
|
||||
free(login);
|
||||
login = strdup("adminn");
|
||||
abort_unless(login != NULL, "returned NULL!");
|
||||
result = Curl_parsenetrc("example.com", &login, &password,
|
||||
&login_changed, &password_changed, filename);
|
||||
fail_unless(result == 0, "Host should have been found");
|
||||
abort_unless(password != NULL, "returned NULL!");
|
||||
fail_unless(password[0] == 0, "password should not have been changed");
|
||||
fail_unless(!password_changed, "password should not have been changed");
|
||||
abort_unless(login != NULL, "returned NULL!");
|
||||
fail_unless(strncmp(login, "adminn", 6) == 0,
|
||||
"login should not have been changed");
|
||||
fail_unless(!login_changed, "login should not have been changed");
|
||||
|
||||
/*
|
||||
* Test for the first existing host in our netrc file
|
||||
* with login[0] = 0.
|
||||
*/
|
||||
free(login);
|
||||
login = strdup("");
|
||||
abort_unless(login != NULL, "returned NULL!");
|
||||
result = Curl_parsenetrc("example.com", &login, &password,
|
||||
&login_changed, &password_changed, filename);
|
||||
fail_unless(result == 0, "Host should have been found");
|
||||
abort_unless(password != NULL, "returned NULL!");
|
||||
fail_unless(strncmp(password, "passwd", 6) == 0,
|
||||
"password should be 'passwd'");
|
||||
fail_unless(password_changed, "password should have been changed");
|
||||
abort_unless(login != NULL, "returned NULL!");
|
||||
fail_unless(strncmp(login, "admin", 5) == 0, "login should be 'admin'");
|
||||
fail_unless(login_changed, "login should have been changed");
|
||||
|
||||
/*
|
||||
* Test for the first existing host in our netrc file
|
||||
* with login[0] != 0.
|
||||
*/
|
||||
free(password);
|
||||
password = strdup("");
|
||||
abort_unless(password != NULL, "returned NULL!");
|
||||
result = Curl_parsenetrc("example.com", &login, &password,
|
||||
&login_changed, &password_changed, filename);
|
||||
fail_unless(result == 0, "Host should have been found");
|
||||
abort_unless(password != NULL, "returned NULL!");
|
||||
fail_unless(strncmp(password, "passwd", 6) == 0,
|
||||
"password should be 'passwd'");
|
||||
fail_unless(password_changed, "password should have been changed");
|
||||
abort_unless(login != NULL, "returned NULL!");
|
||||
fail_unless(strncmp(login, "admin", 5) == 0, "login should be 'admin'");
|
||||
fail_unless(!login_changed, "login should not have been changed");
|
||||
|
||||
/*
|
||||
* Test for the second existing host in our netrc file
|
||||
* with login[0] = 0.
|
||||
*/
|
||||
free(password);
|
||||
password = strdup("");
|
||||
abort_unless(password != NULL, "returned NULL!");
|
||||
free(login);
|
||||
login = strdup("");
|
||||
abort_unless(login != NULL, "returned NULL!");
|
||||
result = Curl_parsenetrc("curl.example.com", &login, &password,
|
||||
&login_changed, &password_changed, filename);
|
||||
fail_unless(result == 0, "Host should have been found");
|
||||
abort_unless(password != NULL, "returned NULL!");
|
||||
fail_unless(strncmp(password, "none", 4) == 0,
|
||||
"password should be 'none'");
|
||||
fail_unless(password_changed, "password should have been changed");
|
||||
abort_unless(login != NULL, "returned NULL!");
|
||||
fail_unless(strncmp(login, "none", 4) == 0, "login should be 'none'");
|
||||
fail_unless(login_changed, "login should have been changed");
|
||||
|
||||
/*
|
||||
* Test for the second existing host in our netrc file
|
||||
* with login[0] != 0.
|
||||
*/
|
||||
free(password);
|
||||
password = strdup("");
|
||||
abort_unless(password != NULL, "returned NULL!");
|
||||
result = Curl_parsenetrc("curl.example.com", &login, &password,
|
||||
&login_changed, &password_changed, filename);
|
||||
fail_unless(result == 0, "Host should have been found");
|
||||
abort_unless(password != NULL, "returned NULL!");
|
||||
fail_unless(strncmp(password, "none", 4) == 0,
|
||||
"password should be 'none'");
|
||||
fail_unless(password_changed, "password should have been changed");
|
||||
abort_unless(login != NULL, "returned NULL!");
|
||||
fail_unless(strncmp(login, "none", 4) == 0, "login should be 'none'");
|
||||
fail_unless(!login_changed, "login should not have been changed");
|
||||
|
||||
UNITTEST_STOP
|
||||
132
Engine/lib/curl/tests/unit/unit1305.c
Normal file
132
Engine/lib/curl/tests/unit/unit1305.c
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#define ENABLE_CURLX_PRINTF
|
||||
#include "curlx.h"
|
||||
|
||||
#include "hash.h"
|
||||
#include "hostip.h"
|
||||
|
||||
#include "memdebug.h" /* LAST include file */
|
||||
|
||||
static struct Curl_easy *data;
|
||||
static struct Curl_hash hp;
|
||||
static char *data_key;
|
||||
static struct Curl_dns_entry *data_node;
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
data = curl_easy_init();
|
||||
if(!data) {
|
||||
curl_global_cleanup();
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
Curl_init_dnscache(&hp, 7);
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
if(data_node) {
|
||||
Curl_freeaddrinfo(data_node->addr);
|
||||
free(data_node);
|
||||
}
|
||||
free(data_key);
|
||||
Curl_hash_destroy(&hp);
|
||||
|
||||
curl_easy_cleanup(data);
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
static struct Curl_addrinfo *fake_ai(void)
|
||||
{
|
||||
static struct Curl_addrinfo *ai;
|
||||
static const char dummy[]="dummy";
|
||||
size_t namelen = sizeof(dummy); /* including the zero terminator */
|
||||
|
||||
ai = calloc(1, sizeof(struct Curl_addrinfo) + sizeof(struct sockaddr_in) +
|
||||
namelen);
|
||||
if(!ai)
|
||||
return NULL;
|
||||
|
||||
ai->ai_addr = (void *)((char *)ai + sizeof(struct Curl_addrinfo));
|
||||
ai->ai_canonname = (void *)((char *)ai->ai_addr +
|
||||
sizeof(struct sockaddr_in));
|
||||
memcpy(ai->ai_canonname, dummy, namelen);
|
||||
|
||||
ai->ai_family = AF_INET;
|
||||
ai->ai_addrlen = sizeof(struct sockaddr_in);
|
||||
|
||||
return ai;
|
||||
}
|
||||
|
||||
static CURLcode create_node(void)
|
||||
{
|
||||
data_key = aprintf("%s:%d", "dummy", 0);
|
||||
if(!data_key)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
data_node = calloc(1, sizeof(struct Curl_dns_entry));
|
||||
if(!data_node)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
data_node->addr = fake_ai();
|
||||
if(!data_node->addr)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
struct Curl_dns_entry *nodep;
|
||||
size_t key_len;
|
||||
|
||||
/* Test 1305 exits without adding anything to the hash */
|
||||
if(strcmp(arg, "1305") != 0) {
|
||||
CURLcode rc = create_node();
|
||||
abort_unless(rc == CURLE_OK, "data node creation failed");
|
||||
key_len = strlen(data_key);
|
||||
|
||||
data_node->inuse = 1; /* hash will hold the reference */
|
||||
nodep = Curl_hash_add(&hp, data_key, key_len + 1, data_node);
|
||||
abort_unless(nodep, "insertion into hash failed");
|
||||
/* Freeing will now be done by Curl_hash_destroy */
|
||||
data_node = NULL;
|
||||
}
|
||||
|
||||
UNITTEST_STOP
|
||||
325
Engine/lib/curl/tests/unit/unit1307.c
Normal file
325
Engine/lib/curl/tests/unit/unit1307.c
Normal file
|
|
@ -0,0 +1,325 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "curl_fnmatch.h"
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef CURL_DISABLE_FTP
|
||||
|
||||
/*
|
||||
CURL_FNMATCH_MATCH 0
|
||||
CURL_FNMATCH_NOMATCH 1
|
||||
CURL_FNMATCH_FAIL 2
|
||||
*/
|
||||
|
||||
#define MATCH CURL_FNMATCH_MATCH
|
||||
#define NOMATCH CURL_FNMATCH_NOMATCH
|
||||
|
||||
#define LINUX_DIFFER 0x80
|
||||
#define LINUX_SHIFT 8
|
||||
#define LINUX_MATCH ((CURL_FNMATCH_MATCH << LINUX_SHIFT) | LINUX_DIFFER)
|
||||
#define LINUX_NOMATCH ((CURL_FNMATCH_NOMATCH << LINUX_SHIFT) | LINUX_DIFFER)
|
||||
#define LINUX_FAIL ((CURL_FNMATCH_FAIL << LINUX_SHIFT) | LINUX_DIFFER)
|
||||
|
||||
#define MAC_DIFFER 0x40
|
||||
#define MAC_SHIFT 16
|
||||
#define MAC_MATCH ((CURL_FNMATCH_MATCH << MAC_SHIFT) | MAC_DIFFER)
|
||||
#define MAC_NOMATCH ((CURL_FNMATCH_NOMATCH << MAC_SHIFT) | MAC_DIFFER)
|
||||
#define MAC_FAIL ((CURL_FNMATCH_FAIL << MAC_SHIFT) | MAC_DIFFER)
|
||||
|
||||
struct testcase {
|
||||
const char *pattern;
|
||||
const char *string;
|
||||
int result;
|
||||
};
|
||||
|
||||
static const struct testcase tests[] = {
|
||||
/* brackets syntax */
|
||||
{"*[*[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
|
||||
"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
|
||||
"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[\001\177[[[[[[[[[[[[[[[[[[[[[",
|
||||
"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
|
||||
"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
|
||||
"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[",
|
||||
NOMATCH|MAC_FAIL},
|
||||
|
||||
{ "\\[", "[", MATCH },
|
||||
{ "[", "[", NOMATCH|LINUX_MATCH|MAC_FAIL},
|
||||
{ "[]", "[]", NOMATCH|LINUX_MATCH|MAC_FAIL},
|
||||
{ "[][]", "[", MATCH },
|
||||
{ "[][]", "]", MATCH },
|
||||
{ "[[]", "[", MATCH },
|
||||
{ "[[[]", "[", MATCH },
|
||||
{ "[[[[]", "[", MATCH },
|
||||
{ "[[[[]", "[", MATCH },
|
||||
|
||||
{ "[][[]", "]", MATCH },
|
||||
{ "[][[[]", "[", MATCH },
|
||||
{ "[[]", "]", NOMATCH },
|
||||
|
||||
{ "[a@]", "a", MATCH },
|
||||
|
||||
{ "[a-z]", "a", MATCH },
|
||||
{ "[a-z]", "A", NOMATCH },
|
||||
{ "?[a-z]", "?Z", NOMATCH },
|
||||
{ "[A-Z]", "C", MATCH },
|
||||
{ "[A-Z]", "c", NOMATCH },
|
||||
{ "[0-9]", "7", MATCH },
|
||||
{ "[7-8]", "7", MATCH },
|
||||
{ "[7-]", "7", MATCH },
|
||||
{ "[7-]", "-", MATCH },
|
||||
{ "[7-]", "[", NOMATCH },
|
||||
{ "[a-bA-F]", "F", MATCH },
|
||||
{ "[a-bA-B9]", "9", MATCH },
|
||||
{ "[a-bA-B98]", "8", MATCH },
|
||||
{ "[a-bA-B98]", "C", NOMATCH },
|
||||
{ "[a-bA-Z9]", "F", MATCH },
|
||||
{ "[a-bA-Z9]ero*", "Zero chance.", MATCH },
|
||||
{ "S[a-][x]opho*", "Saxophone", MATCH },
|
||||
{ "S[a-][x]opho*", "SaXophone", NOMATCH },
|
||||
{ "S[a-][x]*.txt", "S-x.txt", MATCH },
|
||||
{ "[\\a-\\b]", "a", MATCH },
|
||||
{ "[\\a-\\b]", "b", MATCH },
|
||||
{ "[?*[][?*[][?*[]", "?*[", MATCH },
|
||||
{ "[][?*-]", "]", MATCH },
|
||||
{ "[][?*-]", "[", MATCH },
|
||||
{ "[][?*-]", "?", MATCH },
|
||||
{ "[][?*-]", "*", MATCH },
|
||||
{ "[][?*-]", "-", MATCH },
|
||||
{ "[]?*-]", "-", MATCH },
|
||||
{ "[\xFF]", "\xFF", MATCH|LINUX_FAIL|MAC_FAIL},
|
||||
{ "?/b/c", "a/b/c", MATCH },
|
||||
{ "^_{}~", "^_{}~", MATCH },
|
||||
{ "!#%+,-./01234567889", "!#%+,-./01234567889", MATCH },
|
||||
{ "PQRSTUVWXYZ]abcdefg", "PQRSTUVWXYZ]abcdefg", MATCH },
|
||||
{ ":;=@ABCDEFGHIJKLMNO", ":;=@ABCDEFGHIJKLMNO", MATCH },
|
||||
|
||||
/* negate */
|
||||
{ "[!a]", "b", MATCH },
|
||||
{ "[!a]", "a", NOMATCH },
|
||||
{ "[^a]", "b", MATCH },
|
||||
{ "[^a]", "a", NOMATCH },
|
||||
{ "[^a-z0-9A-Z]", "a", NOMATCH },
|
||||
{ "[^a-z0-9A-Z]", "-", MATCH },
|
||||
{ "curl[!a-z]lib", "curl lib", MATCH },
|
||||
{ "curl[! ]lib", "curl lib", NOMATCH },
|
||||
{ "[! ][ ]", " ", NOMATCH },
|
||||
{ "[! ][ ]", "a ", MATCH },
|
||||
{ "*[^a].t?t", "a.txt", NOMATCH },
|
||||
{ "*[^a].t?t", "ba.txt", NOMATCH },
|
||||
{ "*[^a].t?t", "ab.txt", MATCH },
|
||||
{ "*[^a]", "", NOMATCH },
|
||||
{ "[!\xFF]", "", NOMATCH|LINUX_FAIL},
|
||||
{ "[!\xFF]", "\xFF", NOMATCH|LINUX_FAIL|MAC_FAIL},
|
||||
{ "[!\xFF]", "a", MATCH|LINUX_FAIL|MAC_FAIL},
|
||||
{ "[!?*[]", "?", NOMATCH },
|
||||
{ "[!!]", "!", NOMATCH },
|
||||
{ "[!!]", "x", MATCH },
|
||||
|
||||
{ "[[:alpha:]]", "a", MATCH },
|
||||
{ "[[:alpha:]]", "9", NOMATCH },
|
||||
{ "[[:alnum:]]", "a", MATCH },
|
||||
{ "[[:alnum:]]", "[", NOMATCH },
|
||||
{ "[[:alnum:]]", "]", NOMATCH },
|
||||
{ "[[:alnum:]]", "9", MATCH },
|
||||
{ "[[:digit:]]", "9", MATCH },
|
||||
{ "[[:xdigit:]]", "9", MATCH },
|
||||
{ "[[:xdigit:]]", "F", MATCH },
|
||||
{ "[[:xdigit:]]", "G", NOMATCH },
|
||||
{ "[[:upper:]]", "U", MATCH },
|
||||
{ "[[:upper:]]", "u", NOMATCH },
|
||||
{ "[[:lower:]]", "l", MATCH },
|
||||
{ "[[:lower:]]", "L", NOMATCH },
|
||||
{ "[[:print:]]", "L", MATCH },
|
||||
{ "[[:print:]]", "\10", NOMATCH },
|
||||
{ "[[:print:]]", "\10", NOMATCH },
|
||||
{ "[[:space:]]", " ", MATCH },
|
||||
{ "[[:space:]]", "x", NOMATCH },
|
||||
{ "[[:graph:]]", " ", NOMATCH },
|
||||
{ "[[:graph:]]", "x", MATCH },
|
||||
{ "[[:blank:]]", "\t", MATCH },
|
||||
{ "[[:blank:]]", " ", MATCH },
|
||||
{ "[[:blank:]]", "\r", NOMATCH },
|
||||
{ "[^[:blank:]]", "\t", NOMATCH },
|
||||
{ "[^[:print:]]", "\10", MATCH },
|
||||
{ "[[:lower:]][[:lower:]]", "ll", MATCH },
|
||||
{ "[[:foo:]]", "bar", NOMATCH|MAC_FAIL},
|
||||
{ "[[:foo:]]", "f]", MATCH|LINUX_NOMATCH|MAC_FAIL},
|
||||
|
||||
{ "Curl[[:blank:]];-)", "Curl ;-)", MATCH },
|
||||
{ "*[[:blank:]]*", " ", MATCH },
|
||||
{ "*[[:blank:]]*", "", NOMATCH },
|
||||
{ "*[[:blank:]]*", "hi, im_Pavel", MATCH },
|
||||
|
||||
/* common using */
|
||||
{ "filename.dat", "filename.dat", MATCH },
|
||||
{ "*curl*", "lets use curl!!", MATCH },
|
||||
{ "filename.txt", "filename.dat", NOMATCH },
|
||||
{ "*.txt", "text.txt", MATCH },
|
||||
{ "*.txt", "a.txt", MATCH },
|
||||
{ "*.txt", ".txt", MATCH },
|
||||
{ "*.txt", "txt", NOMATCH },
|
||||
{ "??.txt", "99.txt", MATCH },
|
||||
{ "??.txt", "a99.txt", NOMATCH },
|
||||
{ "?.???", "a.txt", MATCH },
|
||||
{ "*.???", "somefile.dat", MATCH },
|
||||
{ "*.???", "photo.jpeg", NOMATCH },
|
||||
{ ".*", ".htaccess", MATCH },
|
||||
{ ".*", ".", MATCH },
|
||||
{ ".*", "..", MATCH },
|
||||
|
||||
/* many stars => one star */
|
||||
{ "**.txt", "text.txt", MATCH },
|
||||
{ "***.txt", "t.txt", MATCH },
|
||||
{ "****.txt", ".txt", MATCH },
|
||||
|
||||
/* empty string or pattern */
|
||||
{ "", "", MATCH },
|
||||
{ "", "hello", NOMATCH },
|
||||
{ "file", "", NOMATCH },
|
||||
{ "?", "", NOMATCH },
|
||||
{ "*", "", MATCH },
|
||||
{ "x", "", NOMATCH },
|
||||
|
||||
/* backslash */
|
||||
{ "\\", "\\", MATCH|LINUX_NOMATCH},
|
||||
{ "\\\\", "\\", MATCH },
|
||||
{ "\\\\", "\\\\", NOMATCH },
|
||||
{ "\\?", "?", MATCH },
|
||||
{ "\\*", "*", MATCH },
|
||||
{ "?.txt", "?.txt", MATCH },
|
||||
{ "*.txt", "*.txt", MATCH },
|
||||
{ "\\?.txt", "?.txt", MATCH },
|
||||
{ "\\*.txt", "*.txt", MATCH },
|
||||
{ "\\?.txt", "x.txt", NOMATCH },
|
||||
{ "\\*.txt", "x.txt", NOMATCH },
|
||||
{ "\\*\\\\.txt", "*\\.txt", MATCH },
|
||||
{ "*\\**\\?*\\\\*", "cc*cc?cccc", NOMATCH },
|
||||
{ "*\\?*\\**", "cc?cc", NOMATCH },
|
||||
{ "\\\"\\$\\&\\'\\(\\)", "\"$&'()", MATCH },
|
||||
{ "\\*\\?\\[\\\\\\`\\|", "*?[\\`|", MATCH },
|
||||
{ "[\\a\\b]c", "ac", MATCH },
|
||||
{ "[\\a\\b]c", "bc", MATCH },
|
||||
{ "[\\a\\b]d", "bc", NOMATCH },
|
||||
{ "[a-bA-B\\?]", "?", MATCH },
|
||||
{ "cu[a-ab-b\\r]l", "curl", MATCH },
|
||||
{ "[\\a-z]", "c", MATCH },
|
||||
|
||||
{ "?*?*?.*?*", "abc.c", MATCH },
|
||||
{ "?*?*?.*?*", "abcc", NOMATCH },
|
||||
{ "?*?*?.*?*", "abc.", NOMATCH },
|
||||
{ "?*?*?.*?*", "abc.c++", MATCH },
|
||||
{ "?*?*?.*?*", "abcdef.c++", MATCH },
|
||||
{ "?*?*?.?", "abcdef.c", MATCH },
|
||||
{ "?*?*?.?", "abcdef.cd", NOMATCH },
|
||||
|
||||
{ "Lindmätarv", "Lindmätarv", MATCH },
|
||||
|
||||
{ "", "", MATCH},
|
||||
{"**]*[*[\x13]**[*\x13)]*]*[**[*\x13~r-]*]**[.*]*[\xe3\xe3\xe3\xe3\xe3\xe3"
|
||||
"\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3"
|
||||
"\xe3\xe3\xe3\xe3\xe3*[\x13]**[*\x13)]*]*[*[\x13]*[~r]*]*\xba\x13\xa6~b-]*",
|
||||
"a", NOMATCH|LINUX_FAIL}
|
||||
};
|
||||
|
||||
static const char *ret2name(int i)
|
||||
{
|
||||
switch(i) {
|
||||
case 0:
|
||||
return "MATCH";
|
||||
case 1:
|
||||
return "NOMATCH";
|
||||
case 2:
|
||||
return "FAIL";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
/* not reached */
|
||||
}
|
||||
|
||||
enum system {
|
||||
SYSTEM_CUSTOM,
|
||||
SYSTEM_LINUX,
|
||||
SYSTEM_MACOS
|
||||
};
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
int testnum = sizeof(tests) / sizeof(struct testcase);
|
||||
int i;
|
||||
enum system machine;
|
||||
|
||||
#ifdef HAVE_FNMATCH
|
||||
if(strstr(OS, "apple") || strstr(OS, "darwin")) {
|
||||
machine = SYSTEM_MACOS;
|
||||
}
|
||||
else
|
||||
machine = SYSTEM_LINUX;
|
||||
printf("Tested with system fnmatch(), %s-style\n",
|
||||
machine == SYSTEM_LINUX ? "linux" : "mac");
|
||||
#else
|
||||
printf("Tested with custom fnmatch()\n");
|
||||
machine = SYSTEM_CUSTOM;
|
||||
#endif
|
||||
|
||||
for(i = 0; i < testnum; i++) {
|
||||
int result = tests[i].result;
|
||||
int rc = Curl_fnmatch(NULL, tests[i].pattern, tests[i].string);
|
||||
if(result & (LINUX_DIFFER|MAC_DIFFER)) {
|
||||
if((result & LINUX_DIFFER) && (machine == SYSTEM_LINUX))
|
||||
result >>= LINUX_SHIFT;
|
||||
else if((result & MAC_DIFFER) && (machine == SYSTEM_MACOS))
|
||||
result >>= MAC_SHIFT;
|
||||
result &= 0x03; /* filter off all high bits */
|
||||
}
|
||||
if(rc != result) {
|
||||
printf("Curl_fnmatch(\"%s\", \"%s\") should return %s (returns %s)"
|
||||
" [%d]\n",
|
||||
tests[i].pattern, tests[i].string, ret2name(result),
|
||||
ret2name(rc), i);
|
||||
fail("pattern mismatch");
|
||||
}
|
||||
}
|
||||
}
|
||||
UNITTEST_STOP
|
||||
|
||||
#else
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
/* nothing to do, just fail */
|
||||
return 1;
|
||||
}
|
||||
UNITTEST_STOP
|
||||
|
||||
#endif
|
||||
97
Engine/lib/curl/tests/unit/unit1308.c
Normal file
97
Engine/lib/curl/tests/unit/unit1308.c
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static size_t print_httppost_callback(void *arg, const char *buf, size_t len)
|
||||
{
|
||||
fwrite(buf, len, 1, stdout);
|
||||
(*(size_t *) arg) += len;
|
||||
return len;
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
int rc;
|
||||
struct curl_httppost *post = NULL;
|
||||
struct curl_httppost *last = NULL;
|
||||
size_t total_size = 0;
|
||||
char buffer[] = "test buffer";
|
||||
|
||||
rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "name",
|
||||
CURLFORM_COPYCONTENTS, "content", CURLFORM_END);
|
||||
|
||||
fail_unless(rc == 0, "curl_formadd returned error");
|
||||
|
||||
/* after the first curl_formadd when there's a single entry, both pointers
|
||||
should point to the same struct */
|
||||
fail_unless(post == last, "post and last weren't the same");
|
||||
|
||||
rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "htmlcode",
|
||||
CURLFORM_COPYCONTENTS, "<HTML></HTML>",
|
||||
CURLFORM_CONTENTTYPE, "text/html", CURLFORM_END);
|
||||
|
||||
fail_unless(rc == 0, "curl_formadd returned error");
|
||||
|
||||
rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "name_for_ptrcontent",
|
||||
CURLFORM_PTRCONTENTS, buffer, CURLFORM_END);
|
||||
|
||||
fail_unless(rc == 0, "curl_formadd returned error");
|
||||
|
||||
rc = curl_formget(post, &total_size, print_httppost_callback);
|
||||
|
||||
fail_unless(rc == 0, "curl_formget returned error");
|
||||
|
||||
fail_unless(total_size == 488, "curl_formget got wrong size back");
|
||||
|
||||
curl_formfree(post);
|
||||
|
||||
/* start a new formpost with a file upload and formget */
|
||||
post = last = NULL;
|
||||
|
||||
rc = curl_formadd(&post, &last,
|
||||
CURLFORM_PTRNAME, "name of file field",
|
||||
CURLFORM_FILE, "log/test-1308",
|
||||
CURLFORM_FILENAME, "custom named file",
|
||||
CURLFORM_END);
|
||||
|
||||
fail_unless(rc == 0, "curl_formadd returned error");
|
||||
|
||||
rc = curl_formget(post, &total_size, print_httppost_callback);
|
||||
fail_unless(rc == 0, "curl_formget returned error");
|
||||
fail_unless(total_size == 851, "curl_formget got wrong size back");
|
||||
|
||||
curl_formfree(post);
|
||||
|
||||
UNITTEST_STOP
|
||||
144
Engine/lib/curl/tests/unit/unit1309.c
Normal file
144
Engine/lib/curl/tests/unit/unit1309.c
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "splay.h"
|
||||
#include "warnless.h"
|
||||
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void splayprint(struct Curl_tree *t, int d, char output)
|
||||
{
|
||||
struct Curl_tree *node;
|
||||
int i;
|
||||
int count;
|
||||
if(!t)
|
||||
return;
|
||||
|
||||
splayprint(t->larger, d + 1, output);
|
||||
for(i = 0; i<d; i++)
|
||||
if(output)
|
||||
printf(" ");
|
||||
|
||||
if(output) {
|
||||
printf("%ld.%ld[%d]", (long)t->key.tv_sec,
|
||||
(long)t->key.tv_usec, i);
|
||||
}
|
||||
|
||||
for(count = 0, node = t->samen; node != t; node = node->samen, count++)
|
||||
;
|
||||
|
||||
if(output) {
|
||||
if(count)
|
||||
printf(" [%d more]\n", count);
|
||||
else
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
splayprint(t->smaller, d + 1, output);
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
/* number of nodes to add to the splay tree */
|
||||
#define NUM_NODES 50
|
||||
|
||||
struct Curl_tree *root, *removed;
|
||||
struct Curl_tree nodes[NUM_NODES*3];
|
||||
size_t storage[NUM_NODES*3];
|
||||
int rc;
|
||||
int i, j;
|
||||
struct curltime tv_now = {0, 0};
|
||||
root = NULL; /* the empty tree */
|
||||
|
||||
/* add nodes */
|
||||
for(i = 0; i < NUM_NODES; i++) {
|
||||
struct curltime key;
|
||||
|
||||
key.tv_sec = 0;
|
||||
key.tv_usec = (541*i)%1023;
|
||||
storage[i] = key.tv_usec;
|
||||
nodes[i].payload = &storage[i];
|
||||
root = Curl_splayinsert(key, root, &nodes[i]);
|
||||
}
|
||||
|
||||
puts("Result:");
|
||||
splayprint(root, 0, 1);
|
||||
|
||||
for(i = 0; i < NUM_NODES; i++) {
|
||||
int rem = (i + 7)%NUM_NODES;
|
||||
printf("Tree look:\n");
|
||||
splayprint(root, 0, 1);
|
||||
printf("remove pointer %d, payload %zu\n", rem,
|
||||
*(size_t *)nodes[rem].payload);
|
||||
rc = Curl_splayremove(root, &nodes[rem], &root);
|
||||
if(rc) {
|
||||
/* failed! */
|
||||
printf("remove %d failed!\n", rem);
|
||||
fail("remove");
|
||||
}
|
||||
}
|
||||
|
||||
fail_unless(root == NULL, "tree not empty after removing all nodes");
|
||||
|
||||
/* rebuild tree */
|
||||
for(i = 0; i < NUM_NODES; i++) {
|
||||
struct curltime key;
|
||||
|
||||
key.tv_sec = 0;
|
||||
key.tv_usec = (541*i)%1023;
|
||||
|
||||
/* add some nodes with the same key */
|
||||
for(j = 0; j <= i % 3; j++) {
|
||||
storage[i * 3 + j] = key.tv_usec*10 + j;
|
||||
nodes[i * 3 + j].payload = &storage[i * 3 + j];
|
||||
root = Curl_splayinsert(key, root, &nodes[i * 3 + j]);
|
||||
}
|
||||
}
|
||||
|
||||
removed = NULL;
|
||||
for(i = 0; i <= 1100; i += 100) {
|
||||
printf("Removing nodes not larger than %d\n", i);
|
||||
tv_now.tv_usec = i;
|
||||
root = Curl_splaygetbest(tv_now, root, &removed);
|
||||
while(removed) {
|
||||
printf("removed payload %zu[%zu]\n",
|
||||
(*(size_t *)removed->payload) / 10,
|
||||
(*(size_t *)removed->payload) % 10);
|
||||
root = Curl_splaygetbest(tv_now, root, &removed);
|
||||
}
|
||||
}
|
||||
|
||||
fail_unless(root == NULL, "tree not empty when it should be");
|
||||
|
||||
UNITTEST_STOP
|
||||
68
Engine/lib/curl/tests/unit/unit1323.c
Normal file
68
Engine/lib/curl/tests/unit/unit1323.c
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "timeval.h"
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
struct a {
|
||||
struct curltime first;
|
||||
struct curltime second;
|
||||
time_t result;
|
||||
};
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
struct a tests[] = {
|
||||
{ {36762, 8345 }, {36761, 995926 }, 13 },
|
||||
{ {36761, 995926 }, {36762, 8345 }, -13 },
|
||||
{ {36761, 995926 }, {0, 0}, 36761995 },
|
||||
{ {0, 0}, {36761, 995926 }, -36761995 },
|
||||
};
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
|
||||
timediff_t result = Curl_timediff(tests[i].first, tests[i].second);
|
||||
if(result != tests[i].result) {
|
||||
printf("%d.%06u to %d.%06u got %d, but expected %d\n",
|
||||
tests[i].first.tv_sec,
|
||||
tests[i].first.tv_usec,
|
||||
tests[i].second.tv_sec,
|
||||
tests[i].second.tv_usec,
|
||||
result,
|
||||
tests[i].result);
|
||||
fail("unexpected result!");
|
||||
}
|
||||
}
|
||||
}
|
||||
UNITTEST_STOP
|
||||
43
Engine/lib/curl/tests/unit/unit1330.c
Normal file
43
Engine/lib/curl/tests/unit/unit1330.c
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
char *ptr = malloc(1330);
|
||||
Curl_safefree(ptr);
|
||||
|
||||
UNITTEST_STOP
|
||||
133
Engine/lib/curl/tests/unit/unit1394.c
Normal file
133
Engine/lib/curl/tests/unit/unit1394.c
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "tool_getparam.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "memdebug.h" /* LAST include file */
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
const char *values[] = {
|
||||
/* -E parameter */ /* exp. cert name */ /* exp. passphrase */
|
||||
"foo:bar:baz", "foo", "bar:baz",
|
||||
"foo\\:bar:baz", "foo:bar", "baz",
|
||||
"foo\\\\:bar:baz", "foo\\", "bar:baz",
|
||||
"foo:bar\\:baz", "foo", "bar\\:baz",
|
||||
"foo:bar\\\\:baz", "foo", "bar\\\\:baz",
|
||||
"foo\\bar\\baz", "foo\\bar\\baz", NULL,
|
||||
"foo\\\\bar\\\\baz", "foo\\bar\\baz", NULL,
|
||||
"foo\\", "foo\\", NULL,
|
||||
"foo\\\\", "foo\\", NULL,
|
||||
"foo:bar\\", "foo", "bar\\",
|
||||
"foo:bar\\\\", "foo", "bar\\\\",
|
||||
"foo:bar:", "foo", "bar:",
|
||||
"foo\\::bar\\:", "foo:", "bar\\:",
|
||||
"pkcs11:foobar", "pkcs11:foobar", NULL,
|
||||
"PKCS11:foobar", "PKCS11:foobar", NULL,
|
||||
"PkCs11:foobar", "PkCs11:foobar", NULL,
|
||||
#ifdef WIN32
|
||||
"c:\\foo:bar:baz", "c:\\foo", "bar:baz",
|
||||
"c:\\foo\\:bar:baz", "c:\\foo:bar", "baz",
|
||||
"c:\\foo\\\\:bar:baz", "c:\\foo\\", "bar:baz",
|
||||
"c:\\foo:bar\\:baz", "c:\\foo", "bar\\:baz",
|
||||
"c:\\foo:bar\\\\:baz", "c:\\foo", "bar\\\\:baz",
|
||||
"c:\\foo\\bar\\baz", "c:\\foo\\bar\\baz", NULL,
|
||||
"c:\\foo\\\\bar\\\\baz", "c:\\foo\\bar\\baz", NULL,
|
||||
"c:\\foo\\", "c:\\foo\\", NULL,
|
||||
"c:\\foo\\\\", "c:\\foo\\", NULL,
|
||||
"c:\\foo:bar\\", "c:\\foo", "bar\\",
|
||||
"c:\\foo:bar\\\\", "c:\\foo", "bar\\\\",
|
||||
"c:\\foo:bar:", "c:\\foo", "bar:",
|
||||
"c:\\foo\\::bar\\:", "c:\\foo:", "bar\\:",
|
||||
#endif
|
||||
NULL, NULL, NULL,
|
||||
};
|
||||
const char **p;
|
||||
char *certname, *passphrase;
|
||||
for(p = values; *p; p += 3) {
|
||||
parse_cert_parameter(p[0], &certname, &passphrase);
|
||||
if(p[1]) {
|
||||
if(certname) {
|
||||
if(strcmp(p[1], certname)) {
|
||||
printf("expected certname '%s' but got '%s' "
|
||||
"for -E param '%s'\n", p[1], certname, p[0]);
|
||||
fail("assertion failure");
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("expected certname '%s' but got NULL "
|
||||
"for -E param '%s'\n", p[1], p[0]);
|
||||
fail("assertion failure");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(certname) {
|
||||
printf("expected certname NULL but got '%s' "
|
||||
"for -E param '%s'\n", certname, p[0]);
|
||||
fail("assertion failure");
|
||||
}
|
||||
}
|
||||
if(p[2]) {
|
||||
if(passphrase) {
|
||||
if(strcmp(p[2], passphrase)) {
|
||||
printf("expected passphrase '%s' but got '%s'"
|
||||
"for -E param '%s'\n", p[2], passphrase, p[0]);
|
||||
fail("assertion failure");
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("expected passphrase '%s' but got NULL "
|
||||
"for -E param '%s'\n", p[2], p[0]);
|
||||
fail("assertion failure");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(passphrase) {
|
||||
printf("expected passphrase NULL but got '%s' "
|
||||
"for -E param '%s'\n", passphrase, p[0]);
|
||||
fail("assertion failure");
|
||||
}
|
||||
}
|
||||
if(certname)
|
||||
free(certname);
|
||||
if(passphrase)
|
||||
free(passphrase);
|
||||
}
|
||||
|
||||
UNITTEST_STOP
|
||||
96
Engine/lib/curl/tests/unit/unit1395.c
Normal file
96
Engine/lib/curl/tests/unit/unit1395.c
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "dotdot.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
struct dotdot {
|
||||
const char *input;
|
||||
const char *output;
|
||||
};
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
unsigned int i;
|
||||
int fails = 0;
|
||||
const struct dotdot pairs[] = {
|
||||
{ "/a/b/c/./../../g", "/a/g" },
|
||||
{ "mid/content=5/../6", "mid/6" },
|
||||
{ "/hello/../moo", "/moo" },
|
||||
{ "/1/../1", "/1" },
|
||||
{ "/1/./1", "/1/1" },
|
||||
{ "/1/..", "/" },
|
||||
{ "/1/.", "/1/" },
|
||||
{ "/1/./..", "/" },
|
||||
{ "/1/./../2", "/2" },
|
||||
{ "/hello/1/./../2", "/hello/2" },
|
||||
{ "test/this", "test/this" },
|
||||
{ "test/this/../now", "test/now" },
|
||||
{ "/1../moo../foo", "/1../moo../foo"},
|
||||
{ "/../../moo", "/moo"},
|
||||
{ "/../../moo?andnot/../yay", "/moo?andnot/../yay"},
|
||||
{ "/123?foo=/./&bar=/../", "/123?foo=/./&bar=/../"},
|
||||
{ "/../moo/..?what", "/?what" },
|
||||
{ "/", "/" },
|
||||
{ "", "" },
|
||||
{ "/.../", "/.../" },
|
||||
{ "./moo", "moo" },
|
||||
{ "../moo", "moo" },
|
||||
{ "/.", "/" },
|
||||
{ "/..", "/" },
|
||||
{ "/moo/..", "/" },
|
||||
{ "..", "" },
|
||||
{ ".", "" },
|
||||
};
|
||||
|
||||
for(i = 0; i < sizeof(pairs)/sizeof(pairs[0]); i++) {
|
||||
char *out = Curl_dedotdotify(pairs[i].input);
|
||||
abort_unless(out != NULL, "returned NULL!");
|
||||
|
||||
if(strcmp(out, pairs[i].output)) {
|
||||
fprintf(stderr, "Test %u: '%s' gave '%s' instead of '%s'\n",
|
||||
i, pairs[i].input, out, pairs[i].output);
|
||||
fail("Test case output mismatched");
|
||||
fails++;
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "Test %u: OK\n", i);
|
||||
free(out);
|
||||
}
|
||||
|
||||
fail_if(fails, "output mismatched");
|
||||
|
||||
UNITTEST_STOP
|
||||
117
Engine/lib/curl/tests/unit/unit1396.c
Normal file
117
Engine/lib/curl/tests/unit/unit1396.c
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
static CURL *hnd;
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
return res;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
if(hnd)
|
||||
curl_easy_cleanup(hnd);
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
struct test {
|
||||
const char *in;
|
||||
int inlen;
|
||||
const char *out;
|
||||
int outlen;
|
||||
};
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
/* unescape, this => that */
|
||||
const struct test list1[]={
|
||||
{"%61", 3, "a", 1},
|
||||
{"%61a", 4, "aa", 2},
|
||||
{"%61b", 4, "ab", 2},
|
||||
{"%6 1", 4, "%6 1", 4},
|
||||
{"%61", 1, "%", 1},
|
||||
{"%61", 2, "%6", 2},
|
||||
{"%6%a", 4, "%6%a", 4},
|
||||
{"%6a", 0, "j", 1},
|
||||
{"%FF", 0, "\xff", 1},
|
||||
{"%FF%00%ff", 9, "\xff\x00\xff", 3},
|
||||
{"%-2", 0, "%-2", 3},
|
||||
{"%FG", 0, "%FG", 3},
|
||||
{NULL, 0, NULL, 0} /* end of list marker */
|
||||
};
|
||||
/* escape, this => that */
|
||||
const struct test list2[]={
|
||||
{"a", 1, "a", 1},
|
||||
{"/", 1, "%2F", 3},
|
||||
{"a=b", 3, "a%3Db", 5},
|
||||
{"a=b", 0, "a%3Db", 5},
|
||||
{"a=b", 1, "a", 1},
|
||||
{"a=b", 2, "a%3D", 4},
|
||||
{"1/./0", 5, "1%2F.%2F0", 9},
|
||||
{"-._~!#%&", 0, "-._~%21%23%25%26", 16},
|
||||
{"a", 2, "a%00", 4},
|
||||
{"a\xff\x01g", 4, "a%FF%01g", 8},
|
||||
{NULL, 0, NULL, 0} /* end of list marker */
|
||||
};
|
||||
int i;
|
||||
|
||||
hnd = curl_easy_init();
|
||||
abort_unless(hnd != NULL, "returned NULL!");
|
||||
for(i = 0; list1[i].in; i++) {
|
||||
int outlen;
|
||||
char *out = curl_easy_unescape(hnd,
|
||||
list1[i].in, list1[i].inlen,
|
||||
&outlen);
|
||||
|
||||
abort_unless(out != NULL, "returned NULL!");
|
||||
fail_unless(outlen == list1[i].outlen, "wrong output length returned");
|
||||
fail_unless(!memcmp(out, list1[i].out, list1[i].outlen),
|
||||
"bad output data returned");
|
||||
|
||||
printf("curl_easy_unescape test %d DONE\n", i);
|
||||
|
||||
curl_free(out);
|
||||
}
|
||||
|
||||
for(i = 0; list2[i].in; i++) {
|
||||
int outlen;
|
||||
char *out = curl_easy_escape(hnd, list2[i].in, list2[i].inlen);
|
||||
abort_unless(out != NULL, "returned NULL!");
|
||||
|
||||
outlen = (int)strlen(out);
|
||||
fail_unless(outlen == list2[i].outlen, "wrong output length returned");
|
||||
fail_unless(!memcmp(out, list2[i].out, list2[i].outlen),
|
||||
"bad output data returned");
|
||||
|
||||
printf("curl_easy_escape test %d DONE (%s)\n", i, out);
|
||||
|
||||
curl_free(out);
|
||||
}
|
||||
}
|
||||
UNITTEST_STOP
|
||||
94
Engine/lib/curl/tests/unit/unit1397.c
Normal file
94
Engine/lib/curl/tests/unit/unit1397.c
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "vtls/hostcheck.h" /* from the lib dir */
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
/* done before shutting down and exiting */
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
/* only these backends define the tested functions */
|
||||
#if defined(USE_OPENSSL) || defined(USE_GSKIT)
|
||||
|
||||
/* here you start doing things and checking that the results are good */
|
||||
|
||||
fail_unless(Curl_cert_hostcheck(STRCONST("www.example.com"),
|
||||
STRCONST("www.example.com")), "good 1");
|
||||
fail_unless(Curl_cert_hostcheck(STRCONST("*.example.com"),
|
||||
STRCONST("www.example.com")),
|
||||
"good 2");
|
||||
fail_unless(Curl_cert_hostcheck(STRCONST("xxx*.example.com"),
|
||||
STRCONST("xxxwww.example.com")), "good 3");
|
||||
fail_unless(Curl_cert_hostcheck(STRCONST("f*.example.com"),
|
||||
STRCONST("foo.example.com")), "good 4");
|
||||
fail_unless(Curl_cert_hostcheck(STRCONST("192.168.0.0"),
|
||||
STRCONST("192.168.0.0")), "good 5");
|
||||
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("xxx.example.com"),
|
||||
STRCONST("www.example.com")), "bad 1");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*"),
|
||||
STRCONST("www.example.com")),"bad 2");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*.*.com"),
|
||||
STRCONST("www.example.com")), "bad 3");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*.example.com"),
|
||||
STRCONST("baa.foo.example.com")), "bad 4");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("f*.example.com"),
|
||||
STRCONST("baa.example.com")), "bad 5");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*.com"),
|
||||
STRCONST("example.com")), "bad 6");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*fail.com"),
|
||||
STRCONST("example.com")), "bad 7");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*.example."),
|
||||
STRCONST("www.example.")), "bad 8");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*.example."),
|
||||
STRCONST("www.example")), "bad 9");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST(""), STRCONST("www")), "bad 10");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*"), STRCONST("www")), "bad 11");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*.168.0.0"),
|
||||
STRCONST("192.168.0.0")), "bad 12");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("www.example.com"),
|
||||
STRCONST("192.168.0.0")), "bad 13");
|
||||
|
||||
#ifdef ENABLE_IPV6
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*::3285:a9ff:fe46:b619"),
|
||||
STRCONST("fe80::3285:a9ff:fe46:b619")), "bad 14");
|
||||
fail_unless(Curl_cert_hostcheck(STRCONST("fe80::3285:a9ff:fe46:b619"),
|
||||
STRCONST("fe80::3285:a9ff:fe46:b619")),
|
||||
"good 6");
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* you end the test code like this: */
|
||||
|
||||
UNITTEST_STOP
|
||||
92
Engine/lib/curl/tests/unit/unit1398.c
Normal file
92
Engine/lib/curl/tests/unit/unit1398.c
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "curl/mprintf.h"
|
||||
|
||||
static CURLcode unit_setup(void) {return CURLE_OK;}
|
||||
static void unit_stop(void) {}
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
int rc;
|
||||
char buf[3] = {'b', 'u', 'g'};
|
||||
const char *str = "bug";
|
||||
int width = 3;
|
||||
char output[24];
|
||||
|
||||
/*#define curl_msnprintf snprintf */
|
||||
|
||||
/* without a trailing zero */
|
||||
rc = curl_msnprintf(output, 4, "%.*s", width, buf);
|
||||
fail_unless(rc == 3, "return code should be 3");
|
||||
fail_unless(!strcmp(output, "bug"), "wrong output");
|
||||
|
||||
/* with a trailing zero */
|
||||
rc = curl_msnprintf(output, 4, "%.*s", width, str);
|
||||
fail_unless(rc == 3, "return code should be 3");
|
||||
fail_unless(!strcmp(output, "bug"), "wrong output");
|
||||
|
||||
width = 2;
|
||||
/* one byte less */
|
||||
rc = curl_msnprintf(output, 4, "%.*s", width, buf);
|
||||
fail_unless(rc == 2, "return code should be 2");
|
||||
fail_unless(!strcmp(output, "bu"), "wrong output");
|
||||
|
||||
/* string with larger precision */
|
||||
rc = curl_msnprintf(output, 8, "%.8s", str);
|
||||
fail_unless(rc == 3, "return code should be 3");
|
||||
fail_unless(!strcmp(output, "bug"), "wrong output");
|
||||
|
||||
/* longer string with precision */
|
||||
rc = curl_msnprintf(output, 8, "%.3s", "0123456789");
|
||||
fail_unless(rc == 3, "return code should be 3");
|
||||
fail_unless(!strcmp(output, "012"), "wrong output");
|
||||
|
||||
/* negative width */
|
||||
rc = curl_msnprintf(output, 8, "%-8s", str);
|
||||
fail_unless(rc == 7, "return code should be 7");
|
||||
fail_unless(!strcmp(output, "bug "), "wrong output");
|
||||
|
||||
/* larger width that string length */
|
||||
rc = curl_msnprintf(output, 8, "%8s", str);
|
||||
fail_unless(rc == 7, "return code should be 7");
|
||||
fail_unless(!strcmp(output, " bu"), "wrong output");
|
||||
|
||||
/* output a number in a limited output */
|
||||
rc = curl_msnprintf(output, 4, "%d", 10240);
|
||||
fail_unless(rc == 3, "return code should be 3");
|
||||
fail_unless(!strcmp(output, "102"), "wrong output");
|
||||
|
||||
/* padded strings */
|
||||
rc = curl_msnprintf(output, 16, "%8s%8s", str, str);
|
||||
fail_unless(rc == 15, "return code should be 15");
|
||||
fail_unless(!strcmp(output, " bug bu"), "wrong output");
|
||||
|
||||
/* padded numbers */
|
||||
rc = curl_msnprintf(output, 16, "%8d%8d", 1234, 5678);
|
||||
fail_unless(rc == 15, "return code should be 15");
|
||||
fail_unless(!strcmp(output, " 1234 567"), "wrong output");
|
||||
|
||||
UNITTEST_STOP
|
||||
119
Engine/lib/curl/tests/unit/unit1399.c
Normal file
119
Engine/lib/curl/tests/unit/unit1399.c
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "urldata.h"
|
||||
#include "progress.h"
|
||||
|
||||
static int usec_magnitude = 1000000;
|
||||
|
||||
static bool unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Invoke Curl_pgrsTime for TIMER_STARTSINGLE to trigger the behavior that
|
||||
* manages is_t_startransfer_set, but fake the t_startsingle time for purposes
|
||||
* of the test.
|
||||
*/
|
||||
static void fake_t_startsingle_time(struct Curl_easy *data,
|
||||
struct curltime fake_now,
|
||||
int seconds_offset)
|
||||
{
|
||||
Curl_pgrsTime(data, TIMER_STARTSINGLE);
|
||||
data->progress.t_startsingle.tv_sec = fake_now.tv_sec + seconds_offset;
|
||||
data->progress.t_startsingle.tv_usec = fake_now.tv_usec;
|
||||
}
|
||||
|
||||
static bool usec_matches_seconds(timediff_t time_usec, int expected_seconds)
|
||||
{
|
||||
int time_sec = (int)(time_usec / usec_magnitude);
|
||||
bool same = (time_sec == expected_seconds);
|
||||
fprintf(stderr, "is %d us same as %d seconds? %s\n",
|
||||
(int)time_usec, expected_seconds,
|
||||
same?"Yes":"No");
|
||||
return same;
|
||||
}
|
||||
|
||||
static void expect_timer_seconds(struct Curl_easy *data, int seconds)
|
||||
{
|
||||
char msg[64];
|
||||
msnprintf(msg, sizeof(msg), "about %d seconds should have passed", seconds);
|
||||
fail_unless(usec_matches_seconds(data->progress.t_nslookup, seconds), msg);
|
||||
fail_unless(usec_matches_seconds(data->progress.t_connect, seconds), msg);
|
||||
fail_unless(usec_matches_seconds(data->progress.t_appconnect, seconds), msg);
|
||||
fail_unless(usec_matches_seconds(data->progress.t_pretransfer, seconds),
|
||||
msg);
|
||||
fail_unless(usec_matches_seconds(data->progress.t_starttransfer, seconds),
|
||||
msg);
|
||||
}
|
||||
|
||||
/* Scenario: simulate a redirect. When a redirect occurs, t_nslookup,
|
||||
* t_connect, t_appconnect, t_pretransfer, and t_starttransfer are addative.
|
||||
* E.g., if t_starttransfer took 2 seconds initially and took another 1
|
||||
* second for the redirect request, then the resulting t_starttransfer should
|
||||
* be 3 seconds. */
|
||||
UNITTEST_START
|
||||
struct Curl_easy data;
|
||||
struct curltime now = Curl_now();
|
||||
|
||||
data.progress.t_nslookup = 0;
|
||||
data.progress.t_connect = 0;
|
||||
data.progress.t_appconnect = 0;
|
||||
data.progress.t_pretransfer = 0;
|
||||
data.progress.t_starttransfer = 0;
|
||||
data.progress.t_redirect = 0;
|
||||
data.progress.start.tv_sec = now.tv_sec - 2;
|
||||
data.progress.start.tv_usec = now.tv_usec;
|
||||
fake_t_startsingle_time(&data, now, -2);
|
||||
|
||||
Curl_pgrsTime(&data, TIMER_NAMELOOKUP);
|
||||
Curl_pgrsTime(&data, TIMER_CONNECT);
|
||||
Curl_pgrsTime(&data, TIMER_APPCONNECT);
|
||||
Curl_pgrsTime(&data, TIMER_PRETRANSFER);
|
||||
Curl_pgrsTime(&data, TIMER_STARTTRANSFER);
|
||||
|
||||
expect_timer_seconds(&data, 2);
|
||||
|
||||
/* now simulate the redirect */
|
||||
data.progress.t_redirect = data.progress.t_starttransfer + 1;
|
||||
fake_t_startsingle_time(&data, now, -1);
|
||||
|
||||
Curl_pgrsTime(&data, TIMER_NAMELOOKUP);
|
||||
Curl_pgrsTime(&data, TIMER_CONNECT);
|
||||
Curl_pgrsTime(&data, TIMER_APPCONNECT);
|
||||
Curl_pgrsTime(&data, TIMER_PRETRANSFER);
|
||||
/* ensure t_starttransfer is only set on the first invocation by attempting
|
||||
* to set it twice */
|
||||
Curl_pgrsTime(&data, TIMER_STARTTRANSFER);
|
||||
Curl_pgrsTime(&data, TIMER_STARTTRANSFER);
|
||||
|
||||
expect_timer_seconds(&data, 3);
|
||||
UNITTEST_STOP
|
||||
75
Engine/lib/curl/tests/unit/unit1600.c
Normal file
75
Engine/lib/curl/tests/unit/unit1600.c
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "urldata.h"
|
||||
#include "curl_ntlm_core.h"
|
||||
|
||||
static CURL *easy;
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
easy = curl_easy_init();
|
||||
if(!easy) {
|
||||
curl_global_cleanup();
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
curl_easy_cleanup(easy);
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
#if defined(USE_NTLM) && (!defined(USE_WINDOWS_SSPI) || \
|
||||
defined(USE_WIN32_CRYPTO))
|
||||
unsigned char output[21];
|
||||
unsigned char *testp = output;
|
||||
Curl_ntlm_core_mk_nt_hash("1", output);
|
||||
|
||||
verify_memory(testp,
|
||||
"\x69\x94\x3c\x5e\x63\xb4\xd2\xc1\x04\xdb"
|
||||
"\xbc\xc1\x51\x38\xb7\x2b\x00\x00\x00\x00\x00", 21);
|
||||
|
||||
Curl_ntlm_core_mk_nt_hash("hello-you-fool", output);
|
||||
|
||||
verify_memory(testp,
|
||||
"\x39\xaf\x87\xa6\x75\x0a\x7a\x00\xba\xa0"
|
||||
"\xd3\x4f\x04\x9e\xc1\xd0\x00\x00\x00\x00\x00", 21);
|
||||
|
||||
/* !checksrc! disable LONGLINE 2 */
|
||||
Curl_ntlm_core_mk_nt_hash("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", output);
|
||||
|
||||
verify_memory(testp,
|
||||
"\x36\x9d\xae\x06\x84\x7e\xe1\xc1\x4a\x94\x39\xea\x6f\x44\x8c\x65\x00\x00\x00\x00\x00", 21);
|
||||
#endif
|
||||
|
||||
UNITTEST_STOP
|
||||
58
Engine/lib/curl/tests/unit/unit1601.c
Normal file
58
Engine/lib/curl/tests/unit/unit1601.c
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "curl_md5.h"
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
#ifndef CURL_DISABLE_CRYPTO_AUTH
|
||||
const char string1[] = "1";
|
||||
const char string2[] = "hello-you-fool";
|
||||
unsigned char output[MD5_DIGEST_LEN];
|
||||
unsigned char *testp = output;
|
||||
|
||||
Curl_md5it(output, (const unsigned char *) string1, strlen(string1));
|
||||
|
||||
verify_memory(testp, "\xc4\xca\x42\x38\xa0\xb9\x23\x82\x0d\xcc\x50\x9a\x6f"
|
||||
"\x75\x84\x9b", MD5_DIGEST_LEN);
|
||||
|
||||
Curl_md5it(output, (const unsigned char *) string2, strlen(string2));
|
||||
|
||||
verify_memory(testp, "\x88\x67\x0b\x6d\x5d\x74\x2f\xad\xa5\xcd\xf9\xb6\x82"
|
||||
"\x87\x5f\x22", MD5_DIGEST_LEN);
|
||||
#endif
|
||||
|
||||
|
||||
UNITTEST_STOP
|
||||
81
Engine/lib/curl/tests/unit/unit1602.c
Normal file
81
Engine/lib/curl/tests/unit/unit1602.c
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#define ENABLE_CURLX_PRINTF
|
||||
#include "curlx.h"
|
||||
|
||||
#include "hash.h"
|
||||
|
||||
#include "memdebug.h" /* LAST include file */
|
||||
|
||||
static struct Curl_hash hash_static;
|
||||
|
||||
static void mydtor(void *p)
|
||||
{
|
||||
int *ptr = (int *)p;
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
Curl_hash_init(&hash_static, 7, Curl_hash_str,
|
||||
Curl_str_key_compare, mydtor);
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
Curl_hash_destroy(&hash_static);
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
int *value;
|
||||
int *value2;
|
||||
int *nodep;
|
||||
size_t klen = sizeof(int);
|
||||
|
||||
int key = 20;
|
||||
int key2 = 25;
|
||||
|
||||
|
||||
value = malloc(sizeof(int));
|
||||
abort_unless(value != NULL, "Out of memory");
|
||||
*value = 199;
|
||||
nodep = Curl_hash_add(&hash_static, &key, klen, value);
|
||||
if(!nodep)
|
||||
free(value);
|
||||
abort_unless(nodep, "insertion into hash failed");
|
||||
Curl_hash_clean(&hash_static);
|
||||
|
||||
/* Attempt to add another key/value pair */
|
||||
value2 = malloc(sizeof(int));
|
||||
abort_unless(value2 != NULL, "Out of memory");
|
||||
*value2 = 204;
|
||||
nodep = Curl_hash_add(&hash_static, &key2, klen, value2);
|
||||
if(!nodep)
|
||||
free(value2);
|
||||
abort_unless(nodep, "insertion into hash failed");
|
||||
|
||||
UNITTEST_STOP
|
||||
153
Engine/lib/curl/tests/unit/unit1603.c
Normal file
153
Engine/lib/curl/tests/unit/unit1603.c
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2015 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#define ENABLE_CURLX_PRINTF
|
||||
#include "curlx.h"
|
||||
|
||||
#include "hash.h"
|
||||
|
||||
#include "memdebug.h" /* LAST include file */
|
||||
|
||||
static struct Curl_hash hash_static;
|
||||
static const int slots = 3;
|
||||
|
||||
static void mydtor(void *p)
|
||||
{
|
||||
/* Data are statically allocated */
|
||||
(void)p; /* unused */
|
||||
}
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
Curl_hash_init(&hash_static, slots, Curl_hash_str,
|
||||
Curl_str_key_compare, mydtor);
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
Curl_hash_destroy(&hash_static);
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
char key1[] = "key1";
|
||||
char key2[] = "key2b";
|
||||
char key3[] = "key3";
|
||||
char key4[] = "key4";
|
||||
char notakey[] = "notakey";
|
||||
char *nodep;
|
||||
int rc;
|
||||
|
||||
/* Ensure the key hashes are as expected in order to test both hash
|
||||
collisions and a full table. Unfortunately, the hashes can vary
|
||||
between architectures. */
|
||||
if(Curl_hash_str(key1, strlen(key1), slots) != 1 ||
|
||||
Curl_hash_str(key2, strlen(key2), slots) != 0 ||
|
||||
Curl_hash_str(key3, strlen(key3), slots) != 2 ||
|
||||
Curl_hash_str(key4, strlen(key4), slots) != 1)
|
||||
fprintf(stderr, "Warning: hashes are not computed as expected on this "
|
||||
"architecture; test coverage will be less comprehensive\n");
|
||||
|
||||
nodep = Curl_hash_add(&hash_static, &key1, strlen(key1), &key1);
|
||||
fail_unless(nodep, "insertion into hash failed");
|
||||
nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
|
||||
fail_unless(nodep == key1, "hash retrieval failed");
|
||||
|
||||
nodep = Curl_hash_add(&hash_static, &key2, strlen(key2), &key2);
|
||||
fail_unless(nodep, "insertion into hash failed");
|
||||
nodep = Curl_hash_pick(&hash_static, &key2, strlen(key2));
|
||||
fail_unless(nodep == key2, "hash retrieval failed");
|
||||
|
||||
nodep = Curl_hash_add(&hash_static, &key3, strlen(key3), &key3);
|
||||
fail_unless(nodep, "insertion into hash failed");
|
||||
nodep = Curl_hash_pick(&hash_static, &key3, strlen(key3));
|
||||
fail_unless(nodep == key3, "hash retrieval failed");
|
||||
|
||||
/* The fourth element exceeds the number of slots & collides */
|
||||
nodep = Curl_hash_add(&hash_static, &key4, strlen(key4), &key4);
|
||||
fail_unless(nodep, "insertion into hash failed");
|
||||
nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
|
||||
fail_unless(nodep == key4, "hash retrieval failed");
|
||||
|
||||
/* Make sure all elements are still accessible */
|
||||
nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
|
||||
fail_unless(nodep == key1, "hash retrieval failed");
|
||||
nodep = Curl_hash_pick(&hash_static, &key2, strlen(key2));
|
||||
fail_unless(nodep == key2, "hash retrieval failed");
|
||||
nodep = Curl_hash_pick(&hash_static, &key3, strlen(key3));
|
||||
fail_unless(nodep == key3, "hash retrieval failed");
|
||||
nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
|
||||
fail_unless(nodep == key4, "hash retrieval failed");
|
||||
|
||||
/* Delete the second of two entries in a bucket */
|
||||
rc = Curl_hash_delete(&hash_static, &key4, strlen(key4));
|
||||
fail_unless(rc == 0, "hash delete failed");
|
||||
nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
|
||||
fail_unless(nodep == key1, "hash retrieval failed");
|
||||
nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
|
||||
fail_unless(!nodep, "hash retrieval should have failed");
|
||||
|
||||
/* Insert that deleted node again */
|
||||
nodep = Curl_hash_add(&hash_static, &key4, strlen(key4), &key4);
|
||||
fail_unless(nodep, "insertion into hash failed");
|
||||
nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
|
||||
fail_unless(nodep == key4, "hash retrieval failed");
|
||||
|
||||
/* Delete the first of two entries in a bucket */
|
||||
rc = Curl_hash_delete(&hash_static, &key1, strlen(key1));
|
||||
fail_unless(rc == 0, "hash delete failed");
|
||||
nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
|
||||
fail_unless(!nodep, "hash retrieval should have failed");
|
||||
nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
|
||||
fail_unless(nodep == key4, "hash retrieval failed");
|
||||
|
||||
/* Delete the remaining one of two entries in a bucket */
|
||||
rc = Curl_hash_delete(&hash_static, &key4, strlen(key4));
|
||||
fail_unless(rc == 0, "hash delete failed");
|
||||
nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
|
||||
fail_unless(!nodep, "hash retrieval should have failed");
|
||||
nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
|
||||
fail_unless(!nodep, "hash retrieval should have failed");
|
||||
|
||||
/* Delete an already deleted node */
|
||||
rc = Curl_hash_delete(&hash_static, &key4, strlen(key4));
|
||||
fail_unless(rc, "hash delete should have failed");
|
||||
|
||||
/* Replace an existing node */
|
||||
nodep = Curl_hash_add(&hash_static, &key1, strlen(key1), ¬akey);
|
||||
fail_unless(nodep, "insertion into hash failed");
|
||||
nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
|
||||
fail_unless(nodep == notakey, "hash retrieval failed");
|
||||
|
||||
/* Make sure all remaining elements are still accessible */
|
||||
nodep = Curl_hash_pick(&hash_static, &key2, strlen(key2));
|
||||
fail_unless(nodep == key2, "hash retrieval failed");
|
||||
nodep = Curl_hash_pick(&hash_static, &key3, strlen(key3));
|
||||
fail_unless(nodep == key3, "hash retrieval failed");
|
||||
|
||||
/* Clean up */
|
||||
Curl_hash_clean(&hash_static);
|
||||
|
||||
UNITTEST_STOP
|
||||
358
Engine/lib/curl/tests/unit/unit1604.c
Normal file
358
Engine/lib/curl/tests/unit/unit1604.c
Normal file
|
|
@ -0,0 +1,358 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "tool_cfgable.h"
|
||||
#include "tool_doswin.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "memdebug.h" /* LAST include file */
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#if defined(MSDOS) || defined(WIN32)
|
||||
|
||||
static char *getflagstr(int flags)
|
||||
{
|
||||
char *buf = malloc(256);
|
||||
if(buf) {
|
||||
msnprintf(buf, 256, "%s,%s,%s,%s",
|
||||
((flags & SANITIZE_ALLOW_COLONS) ?
|
||||
"SANITIZE_ALLOW_COLONS" : ""),
|
||||
((flags & SANITIZE_ALLOW_PATH) ?
|
||||
"SANITIZE_ALLOW_PATH" : ""),
|
||||
((flags & SANITIZE_ALLOW_RESERVED) ?
|
||||
"SANITIZE_ALLOW_RESERVED" : ""),
|
||||
((flags & SANITIZE_ALLOW_TRUNCATE) ?
|
||||
"SANITIZE_ALLOW_TRUNCATE" : ""));
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
static char *getcurlcodestr(int cc)
|
||||
{
|
||||
char *buf = malloc(256);
|
||||
if(buf) {
|
||||
msnprintf(buf, 256, "%s (%d)",
|
||||
(cc == SANITIZE_ERR_OK ? "SANITIZE_ERR_OK" :
|
||||
cc == SANITIZE_ERR_BAD_ARGUMENT ? "SANITIZE_ERR_BAD_ARGUMENT" :
|
||||
cc == SANITIZE_ERR_INVALID_PATH ? "SANITIZE_ERR_INVALID_PATH" :
|
||||
cc == SANITIZE_ERR_OUT_OF_MEMORY ? "SANITIZE_ERR_OUT_OF_MEMORY":
|
||||
"unexpected error code - add name"),
|
||||
cc);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
struct data {
|
||||
const char *input;
|
||||
int flags;
|
||||
const char *expected_output;
|
||||
SANITIZEcode expected_result;
|
||||
};
|
||||
|
||||
UNITTEST_START
|
||||
{ /* START sanitize_file_name */
|
||||
struct data data[] = {
|
||||
{ "", 0,
|
||||
"", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "normal filename", 0,
|
||||
"normal filename", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "control\tchar", 0,
|
||||
"control_char", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "banned*char", 0,
|
||||
"banned_char", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "f:foo", 0,
|
||||
"f_foo", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "f:foo", SANITIZE_ALLOW_COLONS,
|
||||
"f:foo", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "f:foo", SANITIZE_ALLOW_PATH,
|
||||
"f:foo", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "f:\\foo", 0,
|
||||
"f__foo", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "f:\\foo", SANITIZE_ALLOW_PATH,
|
||||
"f:\\foo", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "f:/foo", 0,
|
||||
"f__foo", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "f:/foo", SANITIZE_ALLOW_PATH,
|
||||
"f:/foo", SANITIZE_ERR_OK
|
||||
},
|
||||
#ifndef MSDOS
|
||||
{ "\\\\?\\C:\\foo", SANITIZE_ALLOW_PATH,
|
||||
"\\\\?\\C:\\foo", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "\\\\?\\C:\\foo", 0,
|
||||
"____C__foo", SANITIZE_ERR_OK
|
||||
},
|
||||
#endif
|
||||
{ "foo:bar", 0,
|
||||
"foo_bar", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "foo|<>/bar\\\":?*baz", 0,
|
||||
"foo____bar_____baz", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "f:foo::$DATA", 0,
|
||||
"f_foo__$DATA", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "con . air", 0,
|
||||
"con _ air", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "con.air", 0,
|
||||
"con_air", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "con:/x", 0,
|
||||
"con__x", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "file . . . . .. .", 0,
|
||||
"file", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "foo . . ? . . ", 0,
|
||||
"foo . . _", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "com1", 0,
|
||||
"_com1", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "com1", SANITIZE_ALLOW_RESERVED,
|
||||
"com1", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "f:\\com1", 0,
|
||||
"f__com1", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "f:\\com1", SANITIZE_ALLOW_PATH,
|
||||
"f:\\_com1", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "f:\\com1", SANITIZE_ALLOW_RESERVED,
|
||||
"f__com1", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "f:\\com1", SANITIZE_ALLOW_RESERVED | SANITIZE_ALLOW_COLONS,
|
||||
"f:_com1", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "f:\\com1", SANITIZE_ALLOW_RESERVED | SANITIZE_ALLOW_PATH,
|
||||
"f:\\com1", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "com1:\\com1", SANITIZE_ALLOW_PATH,
|
||||
"_com1:\\_com1", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "com1:\\com1", SANITIZE_ALLOW_RESERVED | SANITIZE_ALLOW_PATH,
|
||||
"com1:\\com1", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "com1:\\com1", SANITIZE_ALLOW_RESERVED,
|
||||
"com1__com1", SANITIZE_ERR_OK
|
||||
},
|
||||
#ifndef MSDOS
|
||||
{ "\\com1", SANITIZE_ALLOW_PATH,
|
||||
"\\_com1", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "\\\\com1", SANITIZE_ALLOW_PATH,
|
||||
"\\\\com1", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "\\\\?\\C:\\com1", SANITIZE_ALLOW_PATH,
|
||||
"\\\\?\\C:\\com1", SANITIZE_ERR_OK
|
||||
},
|
||||
#endif
|
||||
{ "CoM1", 0,
|
||||
"_CoM1", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "CoM1", SANITIZE_ALLOW_RESERVED,
|
||||
"CoM1", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "COM56", 0,
|
||||
"COM56", SANITIZE_ERR_OK
|
||||
},
|
||||
/* At the moment we expect a maximum path length of 259. I assume MSDOS
|
||||
has variable max path lengths depending on compiler that are shorter
|
||||
so currently these "good" truncate tests won't run on MSDOS */
|
||||
#ifndef MSDOS
|
||||
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
|
||||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
|
||||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
SANITIZE_ALLOW_TRUNCATE,
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
|
||||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
|
||||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
|
||||
"FFFFF", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
|
||||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
|
||||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
|
||||
"FFF\\FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
SANITIZE_ALLOW_TRUNCATE | SANITIZE_ALLOW_PATH,
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
|
||||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
|
||||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
|
||||
"FFF\\FFFFF", SANITIZE_ERR_OK
|
||||
},
|
||||
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
|
||||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
|
||||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
|
||||
"FFF\\FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
SANITIZE_ALLOW_TRUNCATE,
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
|
||||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
|
||||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
|
||||
"FFF_F", SANITIZE_ERR_OK
|
||||
},
|
||||
#endif /* !MSDOS */
|
||||
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
|
||||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
|
||||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
0,
|
||||
NULL, SANITIZE_ERR_INVALID_PATH
|
||||
},
|
||||
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
|
||||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
|
||||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
|
||||
"FFFF\\FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
SANITIZE_ALLOW_TRUNCATE,
|
||||
NULL, SANITIZE_ERR_INVALID_PATH
|
||||
},
|
||||
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
|
||||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
|
||||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFF\\FFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
SANITIZE_ALLOW_TRUNCATE | SANITIZE_ALLOW_PATH,
|
||||
NULL, SANITIZE_ERR_INVALID_PATH
|
||||
},
|
||||
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
|
||||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
|
||||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
|
||||
"FFF\\FFFFFFFFFFFFFFFFFFFFF:FFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
SANITIZE_ALLOW_TRUNCATE | SANITIZE_ALLOW_PATH,
|
||||
NULL, SANITIZE_ERR_INVALID_PATH
|
||||
},
|
||||
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
|
||||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
|
||||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
|
||||
"FF\\F:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
SANITIZE_ALLOW_TRUNCATE | SANITIZE_ALLOW_PATH,
|
||||
NULL, SANITIZE_ERR_INVALID_PATH
|
||||
},
|
||||
{ NULL, 0,
|
||||
NULL, SANITIZE_ERR_BAD_ARGUMENT
|
||||
},
|
||||
};
|
||||
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < sizeof(data) / sizeof(data[0]); ++i) {
|
||||
char *output = NULL;
|
||||
char *flagstr = NULL;
|
||||
char *received_ccstr = NULL;
|
||||
char *expected_ccstr = NULL;
|
||||
SANITIZEcode res;
|
||||
|
||||
res = sanitize_file_name(&output, data[i].input, data[i].flags);
|
||||
|
||||
if(res == data[i].expected_result &&
|
||||
((!output && !data[i].expected_output) ||
|
||||
(output && data[i].expected_output &&
|
||||
!strcmp(output, data[i].expected_output)))) { /* OK */
|
||||
free(output);
|
||||
continue;
|
||||
}
|
||||
|
||||
flagstr = getflagstr(data[i].flags);
|
||||
abort_unless(flagstr, "out of memory");
|
||||
received_ccstr = getcurlcodestr(res);
|
||||
abort_unless(received_ccstr, "out of memory");
|
||||
expected_ccstr = getcurlcodestr(data[i].expected_result);
|
||||
abort_unless(expected_ccstr, "out of memory");
|
||||
|
||||
unitfail++;
|
||||
fprintf(stderr, "\n"
|
||||
"%s:%d sanitize_file_name failed.\n"
|
||||
"input: %s\n"
|
||||
"flags: %s\n"
|
||||
"output: %s\n"
|
||||
"result: %s\n"
|
||||
"expected output: %s\n"
|
||||
"expected result: %s\n",
|
||||
__FILE__, __LINE__,
|
||||
data[i].input,
|
||||
flagstr,
|
||||
(output ? output : "(null)"),
|
||||
received_ccstr,
|
||||
(data[i].expected_output ? data[i].expected_output : "(null)"),
|
||||
expected_ccstr);
|
||||
|
||||
free(output);
|
||||
free(flagstr);
|
||||
free(received_ccstr);
|
||||
free(expected_ccstr);
|
||||
}
|
||||
} /* END sanitize_file_name */
|
||||
|
||||
#else
|
||||
UNITTEST_START
|
||||
{
|
||||
fprintf(stderr, "Skipped test not for this platform\n");
|
||||
}
|
||||
#endif /* MSDOS || WIN32 */
|
||||
|
||||
UNITTEST_STOP
|
||||
59
Engine/lib/curl/tests/unit/unit1605.c
Normal file
59
Engine/lib/curl/tests/unit/unit1605.c
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "llist.h"
|
||||
|
||||
static CURL *easy;
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
easy = curl_easy_init();
|
||||
if(!easy) {
|
||||
curl_global_cleanup();
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
curl_easy_cleanup(easy);
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
int len;
|
||||
char *esc;
|
||||
|
||||
esc = curl_easy_escape(easy, "", -1);
|
||||
fail_unless(esc == NULL, "negative string length can't work");
|
||||
|
||||
esc = curl_easy_unescape(easy, "%41%41%41%41", -1, &len);
|
||||
fail_unless(esc == NULL, "negative string length can't work");
|
||||
|
||||
UNITTEST_STOP
|
||||
93
Engine/lib/curl/tests/unit/unit1606.c
Normal file
93
Engine/lib/curl/tests/unit/unit1606.c
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "speedcheck.h"
|
||||
#include "urldata.h"
|
||||
|
||||
static CURL *easy;
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
easy = curl_easy_init();
|
||||
if(!easy) {
|
||||
curl_global_cleanup();
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
curl_easy_cleanup(easy);
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
static int runawhile(long time_limit,
|
||||
long speed_limit,
|
||||
curl_off_t speed,
|
||||
int dec)
|
||||
{
|
||||
int counter = 1;
|
||||
struct curltime now = {1, 0};
|
||||
CURLcode result;
|
||||
int finaltime;
|
||||
|
||||
curl_easy_setopt(easy, CURLOPT_LOW_SPEED_LIMIT, speed_limit);
|
||||
curl_easy_setopt(easy, CURLOPT_LOW_SPEED_TIME, time_limit);
|
||||
Curl_speedinit(easy);
|
||||
|
||||
do {
|
||||
/* fake the current transfer speed */
|
||||
easy->progress.current_speed = speed;
|
||||
result = Curl_speedcheck(easy, now);
|
||||
if(result)
|
||||
break;
|
||||
/* step the time */
|
||||
now.tv_sec = ++counter;
|
||||
speed -= dec;
|
||||
} while(counter < 100);
|
||||
|
||||
finaltime = (int)(now.tv_sec - 1);
|
||||
|
||||
return finaltime;
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
fail_unless(runawhile(41, 41, 40, 0) == 41,
|
||||
"wrong low speed timeout");
|
||||
fail_unless(runawhile(21, 21, 20, 0) == 21,
|
||||
"wrong low speed timeout");
|
||||
fail_unless(runawhile(60, 60, 40, 0) == 60,
|
||||
"wrong log speed timeout");
|
||||
fail_unless(runawhile(50, 50, 40, 0) == 50,
|
||||
"wrong log speed timeout");
|
||||
fail_unless(runawhile(40, 40, 40, 0) == 99,
|
||||
"should not time out");
|
||||
fail_unless(runawhile(10, 50, 100, 2) == 36,
|
||||
"bad timeout");
|
||||
UNITTEST_STOP
|
||||
235
Engine/lib/curl/tests/unit/unit1607.c
Normal file
235
Engine/lib/curl/tests/unit/unit1607.c
Normal file
|
|
@ -0,0 +1,235 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "urldata.h"
|
||||
#include "connect.h"
|
||||
#include "share.h"
|
||||
|
||||
#include "memdebug.h" /* LAST include file */
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
struct testcase {
|
||||
/* host:port:address[,address]... */
|
||||
const char *optval;
|
||||
|
||||
/* lowercase host and port to retrieve the addresses from hostcache */
|
||||
const char *host;
|
||||
int port;
|
||||
|
||||
/* whether we expect a permanent or non-permanent cache entry */
|
||||
bool permanent;
|
||||
|
||||
/* 0 to 9 addresses expected from hostcache */
|
||||
const char *address[10];
|
||||
};
|
||||
|
||||
|
||||
/* In builds without IPv6 support CURLOPT_RESOLVE should skip over those
|
||||
addresses, so we have to do that as well. */
|
||||
static const char skip = 0;
|
||||
#ifdef ENABLE_IPV6
|
||||
#define IPV6ONLY(x) x
|
||||
#else
|
||||
#define IPV6ONLY(x) &skip
|
||||
#endif
|
||||
|
||||
/* CURLOPT_RESOLVE address parsing tests */
|
||||
static const struct testcase tests[] = {
|
||||
/* spaces aren't allowed, for now */
|
||||
{ "test.com:80:127.0.0.1, 127.0.0.2",
|
||||
"test.com", 80, TRUE, { NULL, }
|
||||
},
|
||||
{ "TEST.com:80:,,127.0.0.1,,,127.0.0.2,,,,::1,,,",
|
||||
"test.com", 80, TRUE, { "127.0.0.1", "127.0.0.2", IPV6ONLY("::1"), }
|
||||
},
|
||||
{ "test.com:80:::1,127.0.0.1",
|
||||
"test.com", 80, TRUE, { IPV6ONLY("::1"), "127.0.0.1", }
|
||||
},
|
||||
{ "test.com:80:[::1],127.0.0.1",
|
||||
"test.com", 80, TRUE, { IPV6ONLY("::1"), "127.0.0.1", }
|
||||
},
|
||||
{ "test.com:80:::1",
|
||||
"test.com", 80, TRUE, { IPV6ONLY("::1"), }
|
||||
},
|
||||
{ "test.com:80:[::1]",
|
||||
"test.com", 80, TRUE, { IPV6ONLY("::1"), }
|
||||
},
|
||||
{ "test.com:80:127.0.0.1",
|
||||
"test.com", 80, TRUE, { "127.0.0.1", }
|
||||
},
|
||||
{ "test.com:80:,127.0.0.1",
|
||||
"test.com", 80, TRUE, { "127.0.0.1", }
|
||||
},
|
||||
{ "test.com:80:127.0.0.1,",
|
||||
"test.com", 80, TRUE, { "127.0.0.1", }
|
||||
},
|
||||
{ "test.com:0:127.0.0.1",
|
||||
"test.com", 0, TRUE, { "127.0.0.1", }
|
||||
},
|
||||
{ "+test.com:80:127.0.0.1,",
|
||||
"test.com", 80, FALSE, { "127.0.0.1", }
|
||||
},
|
||||
};
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
int i;
|
||||
int testnum = sizeof(tests) / sizeof(struct testcase);
|
||||
struct Curl_multi *multi = NULL;
|
||||
struct Curl_easy *easy = NULL;
|
||||
struct curl_slist *list = NULL;
|
||||
|
||||
for(i = 0; i < testnum; ++i) {
|
||||
int j;
|
||||
int addressnum = sizeof(tests[i].address) / sizeof(*tests[i].address);
|
||||
struct Curl_addrinfo *addr;
|
||||
struct Curl_dns_entry *dns;
|
||||
void *entry_id;
|
||||
bool problem = false;
|
||||
easy = curl_easy_init();
|
||||
if(!easy)
|
||||
goto error;
|
||||
|
||||
/* create a multi handle and add the easy handle to it so that the
|
||||
hostcache is setup */
|
||||
multi = curl_multi_init();
|
||||
curl_multi_add_handle(multi, easy);
|
||||
|
||||
list = curl_slist_append(NULL, tests[i].optval);
|
||||
if(!list)
|
||||
goto error;
|
||||
curl_easy_setopt(easy, CURLOPT_RESOLVE, list);
|
||||
|
||||
Curl_loadhostpairs(easy);
|
||||
|
||||
entry_id = (void *)aprintf("%s:%d", tests[i].host, tests[i].port);
|
||||
if(!entry_id)
|
||||
goto error;
|
||||
dns = Curl_hash_pick(easy->dns.hostcache, entry_id, strlen(entry_id) + 1);
|
||||
free(entry_id);
|
||||
entry_id = NULL;
|
||||
|
||||
addr = dns ? dns->addr : NULL;
|
||||
|
||||
for(j = 0; j < addressnum; ++j) {
|
||||
int port = 0;
|
||||
char ipaddress[MAX_IPADR_LEN] = {0};
|
||||
|
||||
if(!addr && !tests[i].address[j])
|
||||
break;
|
||||
|
||||
if(tests[i].address[j] == &skip)
|
||||
continue;
|
||||
|
||||
if(addr && !Curl_addr2string(addr->ai_addr, addr->ai_addrlen,
|
||||
ipaddress, &port)) {
|
||||
fprintf(stderr, "%s:%d tests[%d] failed. getaddressinfo failed.\n",
|
||||
__FILE__, __LINE__, i);
|
||||
problem = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(addr && !tests[i].address[j]) {
|
||||
fprintf(stderr, "%s:%d tests[%d] failed. the retrieved addr "
|
||||
"is %s but tests[%d].address[%d] is NULL.\n",
|
||||
__FILE__, __LINE__, i, ipaddress, i, j);
|
||||
problem = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!addr && tests[i].address[j]) {
|
||||
fprintf(stderr, "%s:%d tests[%d] failed. the retrieved addr "
|
||||
"is NULL but tests[%d].address[%d] is %s.\n",
|
||||
__FILE__, __LINE__, i, i, j, tests[i].address[j]);
|
||||
problem = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!curl_strequal(ipaddress, tests[i].address[j])) {
|
||||
fprintf(stderr, "%s:%d tests[%d] failed. the retrieved addr "
|
||||
"%s is not equal to tests[%d].address[%d] %s.\n",
|
||||
__FILE__, __LINE__, i, ipaddress, i, j, tests[i].address[j]);
|
||||
problem = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(port != tests[i].port) {
|
||||
fprintf(stderr, "%s:%d tests[%d] failed. the retrieved port "
|
||||
"for tests[%d].address[%d] is %ld but tests[%d].port is %d.\n",
|
||||
__FILE__, __LINE__, i, i, j, port, i, tests[i].port);
|
||||
problem = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(dns->timestamp && tests[i].permanent) {
|
||||
fprintf(stderr, "%s:%d tests[%d] failed. the timestamp is not zero "
|
||||
"but tests[%d].permanent is TRUE\n",
|
||||
__FILE__, __LINE__, i, i);
|
||||
problem = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(dns->timestamp == 0 && !tests[i].permanent) {
|
||||
fprintf(stderr, "%s:%d tests[%d] failed. the timestamp is zero "
|
||||
"but tests[%d].permanent is FALSE\n",
|
||||
__FILE__, __LINE__, i, i);
|
||||
problem = true;
|
||||
break;
|
||||
}
|
||||
|
||||
addr = addr->ai_next;
|
||||
}
|
||||
|
||||
curl_easy_cleanup(easy);
|
||||
easy = NULL;
|
||||
curl_multi_cleanup(multi);
|
||||
multi = NULL;
|
||||
curl_slist_free_all(list);
|
||||
list = NULL;
|
||||
|
||||
if(problem) {
|
||||
unitfail++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
error:
|
||||
curl_easy_cleanup(easy);
|
||||
curl_multi_cleanup(multi);
|
||||
curl_slist_free_all(list);
|
||||
}
|
||||
UNITTEST_STOP
|
||||
76
Engine/lib/curl/tests/unit/unit1608.c
Normal file
76
Engine/lib/curl/tests/unit/unit1608.c
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "hostip.h"
|
||||
|
||||
CURLcode Curl_shuffle_addr(struct Curl_easy *data,
|
||||
struct Curl_addrinfo **addr);
|
||||
|
||||
#define NUM_ADDRS 8
|
||||
static struct Curl_addrinfo addrs[NUM_ADDRS];
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < NUM_ADDRS - 1; i++) {
|
||||
addrs[i].ai_next = &addrs[i + 1];
|
||||
}
|
||||
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
int i;
|
||||
CURLcode code;
|
||||
struct Curl_addrinfo *addrhead = addrs;
|
||||
|
||||
struct Curl_easy *easy = curl_easy_init();
|
||||
abort_unless(easy, "out of memory");
|
||||
|
||||
code = curl_easy_setopt(easy, CURLOPT_DNS_SHUFFLE_ADDRESSES, 1L);
|
||||
abort_unless(code == CURLE_OK, "curl_easy_setopt failed");
|
||||
|
||||
/* Shuffle repeatedly and make sure that the list changes */
|
||||
for(i = 0; i < 10; i++) {
|
||||
if(CURLE_OK != Curl_shuffle_addr(easy, &addrhead))
|
||||
break;
|
||||
if(addrhead != addrs)
|
||||
break;
|
||||
}
|
||||
|
||||
curl_easy_cleanup(easy);
|
||||
curl_global_cleanup();
|
||||
|
||||
abort_unless(addrhead != addrs, "addresses are not being reordered");
|
||||
|
||||
return 0;
|
||||
}
|
||||
UNITTEST_STOP
|
||||
220
Engine/lib/curl/tests/unit/unit1609.c
Normal file
220
Engine/lib/curl/tests/unit/unit1609.c
Normal file
|
|
@ -0,0 +1,220 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "urldata.h"
|
||||
#include "connect.h"
|
||||
#include "share.h"
|
||||
|
||||
#include "memdebug.h" /* LAST include file */
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
struct testcase {
|
||||
/* host:port:address[,address]... */
|
||||
const char *optval;
|
||||
|
||||
/* lowercase host and port to retrieve the addresses from hostcache */
|
||||
const char *host;
|
||||
int port;
|
||||
|
||||
/* 0 to 9 addresses expected from hostcache */
|
||||
const char *address[10];
|
||||
};
|
||||
|
||||
|
||||
/* CURLOPT_RESOLVE address parsing test - to test the following defect fix:
|
||||
|
||||
1) if there is already existing host:port pair in the DNS cache and
|
||||
we call CURLOPT_RESOLVE, it should also replace addresses.
|
||||
for example, if there is "test.com:80" with address "1.1.1.1"
|
||||
and we called CURLOPT_RESOLVE with address "2.2.2.2", then DNS entry needs to
|
||||
reflect that.
|
||||
|
||||
2) when cached address is already there and close to expire, then by the
|
||||
time request is made, it can get expired. This happens because, when
|
||||
we set address using CURLOPT_RESOLVE,
|
||||
it usually marks as permanent (by setting timestamp to zero). However,
|
||||
if address already exists
|
||||
in the cache, then it does not mark it, but just leaves it as it is.
|
||||
So we fixing this by timestamp to zero if address already exists too.
|
||||
|
||||
Test:
|
||||
|
||||
- insert new entry
|
||||
- verify that timestamp is not zero
|
||||
- call set options with CURLOPT_RESOLVE
|
||||
- then, call Curl_loadhostpairs
|
||||
|
||||
expected result: cached address has zero timestamp.
|
||||
|
||||
- call set options with CURLOPT_RESOLVE with same host:port pair,
|
||||
different address.
|
||||
- then, call Curl_loadhostpairs
|
||||
|
||||
expected result: cached address has zero timestamp and new address
|
||||
*/
|
||||
|
||||
static const struct testcase tests[] = {
|
||||
/* spaces aren't allowed, for now */
|
||||
{ "test.com:80:127.0.0.1",
|
||||
"test.com", 80, { "127.0.0.1", }
|
||||
},
|
||||
{ "test.com:80:127.0.0.2",
|
||||
"test.com", 80, { "127.0.0.2", }
|
||||
},
|
||||
};
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
int i;
|
||||
int testnum = sizeof(tests) / sizeof(struct testcase);
|
||||
struct Curl_multi *multi = NULL;
|
||||
struct Curl_easy *easy = NULL;
|
||||
struct curl_slist *list = NULL;
|
||||
|
||||
/* important: we setup cache outside of the loop
|
||||
and also clean cache after the loop. In contrast,for example,
|
||||
test 1607 sets up and cleans cache on each iteration. */
|
||||
|
||||
for(i = 0; i < testnum; ++i) {
|
||||
int j;
|
||||
int addressnum = sizeof (tests[i].address) / sizeof (*tests[i].address);
|
||||
struct Curl_addrinfo *addr;
|
||||
struct Curl_dns_entry *dns;
|
||||
void *entry_id;
|
||||
bool problem = false;
|
||||
easy = curl_easy_init();
|
||||
if(!easy) {
|
||||
curl_global_cleanup();
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
/* create a multi handle and add the easy handle to it so that the
|
||||
hostcache is setup */
|
||||
multi = curl_multi_init();
|
||||
if(!multi)
|
||||
goto error;
|
||||
curl_multi_add_handle(multi, easy);
|
||||
|
||||
list = curl_slist_append(NULL, tests[i].optval);
|
||||
if(!list)
|
||||
goto error;
|
||||
|
||||
curl_easy_setopt(easy, CURLOPT_RESOLVE, list);
|
||||
|
||||
if(Curl_loadhostpairs(easy))
|
||||
goto error;
|
||||
|
||||
entry_id = (void *)aprintf("%s:%d", tests[i].host, tests[i].port);
|
||||
if(!entry_id)
|
||||
goto error;
|
||||
|
||||
dns = Curl_hash_pick(easy->dns.hostcache, entry_id, strlen(entry_id) + 1);
|
||||
free(entry_id);
|
||||
entry_id = NULL;
|
||||
|
||||
addr = dns ? dns->addr : NULL;
|
||||
|
||||
for(j = 0; j < addressnum; ++j) {
|
||||
int port = 0;
|
||||
char ipaddress[MAX_IPADR_LEN] = {0};
|
||||
|
||||
if(!addr && !tests[i].address[j])
|
||||
break;
|
||||
|
||||
if(addr && !Curl_addr2string(addr->ai_addr, addr->ai_addrlen,
|
||||
ipaddress, &port)) {
|
||||
fprintf(stderr, "%s:%d tests[%d] failed. Curl_addr2string failed.\n",
|
||||
__FILE__, __LINE__, i);
|
||||
problem = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(addr && !tests[i].address[j]) {
|
||||
fprintf(stderr, "%s:%d tests[%d] failed. the retrieved addr "
|
||||
"is %s but tests[%d].address[%d] is NULL.\n",
|
||||
__FILE__, __LINE__, i, ipaddress, i, j);
|
||||
problem = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!addr && tests[i].address[j]) {
|
||||
fprintf(stderr, "%s:%d tests[%d] failed. the retrieved addr "
|
||||
"is NULL but tests[%d].address[%d] is %s.\n",
|
||||
__FILE__, __LINE__, i, i, j, tests[i].address[j]);
|
||||
problem = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!curl_strequal(ipaddress, tests[i].address[j])) {
|
||||
fprintf(stderr, "%s:%d tests[%d] failed. the retrieved addr "
|
||||
"%s is not equal to tests[%d].address[%d] %s.\n",
|
||||
__FILE__, __LINE__, i, ipaddress, i, j, tests[i].address[j]);
|
||||
problem = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(port != tests[i].port) {
|
||||
fprintf(stderr, "%s:%d tests[%d] failed. the retrieved port "
|
||||
"for tests[%d].address[%d] is %ld but tests[%d].port is %d.\n",
|
||||
__FILE__, __LINE__, i, i, j, port, i, tests[i].port);
|
||||
problem = true;
|
||||
break;
|
||||
}
|
||||
|
||||
addr = addr->ai_next;
|
||||
}
|
||||
|
||||
curl_easy_cleanup(easy);
|
||||
easy = NULL;
|
||||
Curl_hash_destroy(&multi->hostcache);
|
||||
curl_multi_cleanup(multi);
|
||||
multi = NULL;
|
||||
curl_slist_free_all(list);
|
||||
list = NULL;
|
||||
|
||||
if(problem) {
|
||||
unitfail++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
goto unit_test_abort;
|
||||
error:
|
||||
curl_easy_cleanup(easy);
|
||||
curl_multi_cleanup(multi);
|
||||
curl_slist_free_all(list);
|
||||
}
|
||||
UNITTEST_STOP
|
||||
64
Engine/lib/curl/tests/unit/unit1610.c
Normal file
64
Engine/lib/curl/tests/unit/unit1610.c
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "curl_sha256.h"
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
CURLcode res = CURLE_OK;
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
return res;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
#ifndef CURL_DISABLE_CRYPTO_AUTH
|
||||
const char string1[] = "1";
|
||||
const char string2[] = "hello-you-fool";
|
||||
unsigned char output[SHA256_DIGEST_LENGTH];
|
||||
unsigned char *testp = output;
|
||||
|
||||
Curl_sha256it(output, (const unsigned char *) string1, strlen(string1));
|
||||
|
||||
verify_memory(testp,
|
||||
"\x6b\x86\xb2\x73\xff\x34\xfc\xe1\x9d\x6b\x80\x4e\xff\x5a\x3f"
|
||||
"\x57\x47\xad\xa4\xea\xa2\x2f\x1d\x49\xc0\x1e\x52\xdd\xb7\x87"
|
||||
"\x5b\x4b", SHA256_DIGEST_LENGTH);
|
||||
|
||||
Curl_sha256it(output, (const unsigned char *) string2, strlen(string2));
|
||||
|
||||
verify_memory(testp,
|
||||
"\xcb\xb1\x6a\x8a\xb9\xcb\xb9\x35\xa8\xcb\xa0\x2e\x28\xc0\x26"
|
||||
"\x30\xd1\x19\x9c\x1f\x02\x17\xf4\x7c\x96\x20\xf3\xef\xe8\x27"
|
||||
"\x15\xae", SHA256_DIGEST_LENGTH);
|
||||
#endif
|
||||
|
||||
|
||||
UNITTEST_STOP
|
||||
60
Engine/lib/curl/tests/unit/unit1611.c
Normal file
60
Engine/lib/curl/tests/unit/unit1611.c
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "curl_md4.h"
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
#ifndef CURL_DISABLE_CRYPTO_AUTH
|
||||
const char string1[] = "1";
|
||||
const char string2[] = "hello-you-fool";
|
||||
unsigned char output[MD4_DIGEST_LENGTH];
|
||||
unsigned char *testp = output;
|
||||
|
||||
Curl_md4it(output, (const unsigned char *) string1, strlen(string1));
|
||||
|
||||
verify_memory(testp,
|
||||
"\x8b\xe1\xec\x69\x7b\x14\xad\x3a\x53\xb3\x71\x43\x61\x20\x64"
|
||||
"\x1d", MD4_DIGEST_LENGTH);
|
||||
|
||||
Curl_md4it(output, (const unsigned char *) string2, strlen(string2));
|
||||
|
||||
verify_memory(testp,
|
||||
"\xa7\x16\x1c\xad\x7e\xbe\xdb\xbc\xf8\xc7\x23\x10\x2d\x2c\xe2"
|
||||
"\x0b", MD4_DIGEST_LENGTH);
|
||||
#endif
|
||||
|
||||
|
||||
UNITTEST_STOP
|
||||
68
Engine/lib/curl/tests/unit/unit1612.c
Normal file
68
Engine/lib/curl/tests/unit/unit1612.c
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "curl_hmac.h"
|
||||
#include "curl_md5.h"
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
#ifndef CURL_DISABLE_CRYPTO_AUTH
|
||||
const char password[] = "Pa55worD";
|
||||
const char string1[] = "1";
|
||||
const char string2[] = "hello-you-fool";
|
||||
unsigned char output[HMAC_MD5_LENGTH];
|
||||
unsigned char *testp = output;
|
||||
|
||||
Curl_hmacit(Curl_HMAC_MD5,
|
||||
(const unsigned char *) password, strlen(password),
|
||||
(const unsigned char *) string1, strlen(string1),
|
||||
output);
|
||||
|
||||
verify_memory(testp,
|
||||
"\xd1\x29\x75\x43\x58\xdc\xab\x78\xdf\xcd\x7f\x2b\x29\x31\x13"
|
||||
"\x37", HMAC_MD5_LENGTH);
|
||||
|
||||
Curl_hmacit(Curl_HMAC_MD5,
|
||||
(const unsigned char *) password, strlen(password),
|
||||
(const unsigned char *) string2, strlen(string2),
|
||||
output);
|
||||
|
||||
verify_memory(testp,
|
||||
"\x75\xf1\xa7\xb9\xf5\x40\xe5\xa4\x98\x83\x9f\x64\x5a\x27\x6d"
|
||||
"\xd0", HMAC_MD5_LENGTH);
|
||||
#endif
|
||||
|
||||
|
||||
UNITTEST_STOP
|
||||
93
Engine/lib/curl/tests/unit/unit1620.c
Normal file
93
Engine/lib/curl/tests/unit/unit1620.c
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "urldata.h"
|
||||
#include "url.h"
|
||||
|
||||
#include "memdebug.h" /* LAST include file */
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
CURLcode res = CURLE_OK;
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
return res;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
int rc;
|
||||
struct Curl_easy *empty;
|
||||
const char *hostname = "hostname";
|
||||
enum dupstring i;
|
||||
|
||||
bool async = FALSE;
|
||||
bool protocol_connect = FALSE;
|
||||
|
||||
rc = Curl_open(&empty);
|
||||
if(rc)
|
||||
goto unit_test_abort;
|
||||
fail_unless(rc == CURLE_OK, "Curl_open() failed");
|
||||
|
||||
rc = Curl_connect(empty, &async, &protocol_connect);
|
||||
fail_unless(rc == CURLE_URL_MALFORMAT,
|
||||
"Curl_connect() failed to return CURLE_URL_MALFORMAT");
|
||||
|
||||
fail_unless(empty->magic == CURLEASY_MAGIC_NUMBER,
|
||||
"empty->magic should be equal to CURLEASY_MAGIC_NUMBER");
|
||||
|
||||
/* double invoke to ensure no dependency on internal state */
|
||||
rc = Curl_connect(empty, &async, &protocol_connect);
|
||||
fail_unless(rc == CURLE_URL_MALFORMAT,
|
||||
"Curl_connect() failed to return CURLE_URL_MALFORMAT");
|
||||
|
||||
rc = Curl_init_userdefined(empty);
|
||||
fail_unless(rc == CURLE_OK, "Curl_userdefined() failed");
|
||||
|
||||
rc = Curl_init_do(empty, empty->conn);
|
||||
fail_unless(rc == CURLE_OK, "Curl_init_do() failed");
|
||||
|
||||
rc = Curl_parse_login_details(
|
||||
hostname, strlen(hostname), NULL, NULL, NULL);
|
||||
fail_unless(rc == CURLE_OK,
|
||||
"Curl_parse_login_details() failed");
|
||||
|
||||
Curl_freeset(empty);
|
||||
for(i = (enum dupstring)0; i < STRING_LAST; i++) {
|
||||
fail_unless(empty->set.str[i] == NULL,
|
||||
"Curl_free() did not set to NULL");
|
||||
}
|
||||
|
||||
Curl_free_request_state(empty);
|
||||
|
||||
rc = Curl_close(&empty);
|
||||
fail_unless(rc == CURLE_OK, "Curl_close() failed");
|
||||
|
||||
}
|
||||
UNITTEST_STOP
|
||||
93
Engine/lib/curl/tests/unit/unit1621.c
Normal file
93
Engine/lib/curl/tests/unit/unit1621.c
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "urldata.h"
|
||||
#include "url.h"
|
||||
|
||||
#include "memdebug.h" /* LAST include file */
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(__MINGW32__) || \
|
||||
(!defined(HAVE_FSETXATTR) && \
|
||||
(!defined(__FreeBSD_version) || (__FreeBSD_version < 500000)))
|
||||
UNITTEST_START
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
UNITTEST_STOP
|
||||
#else
|
||||
|
||||
bool stripcredentials(char **url);
|
||||
|
||||
struct checkthis {
|
||||
const char *input;
|
||||
const char *output;
|
||||
};
|
||||
|
||||
static const struct checkthis tests[] = {
|
||||
{ "ninja://foo@example.com", "ninja://foo@example.com" },
|
||||
{ "https://foo@example.com", "https://example.com/" },
|
||||
{ "https://localhost:45", "https://localhost:45/" },
|
||||
{ "https://foo@localhost:45", "https://localhost:45/" },
|
||||
{ "http://daniel:password@localhost", "http://localhost/" },
|
||||
{ "http://daniel@localhost", "http://localhost/" },
|
||||
{ "http://localhost/", "http://localhost/" },
|
||||
{ NULL, NULL } /* end marker */
|
||||
};
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
bool cleanup;
|
||||
char *url;
|
||||
int i;
|
||||
int rc = 0;
|
||||
|
||||
for(i = 0; tests[i].input; i++) {
|
||||
url = (char *)tests[i].input;
|
||||
cleanup = stripcredentials(&url);
|
||||
printf("Test %u got input \"%s\", output: \"%s\"\n",
|
||||
i, tests[i].input, url);
|
||||
|
||||
if(strcmp(tests[i].output, url)) {
|
||||
fprintf(stderr, "Test %u got input \"%s\", expected output \"%s\"\n"
|
||||
" Actual output: \"%s\"\n", i, tests[i].input, tests[i].output,
|
||||
url);
|
||||
rc++;
|
||||
}
|
||||
if(cleanup)
|
||||
curl_free(url);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
UNITTEST_STOP
|
||||
#endif
|
||||
297
Engine/lib/curl/tests/unit/unit1650.c
Normal file
297
Engine/lib/curl/tests/unit/unit1650.c
Normal file
|
|
@ -0,0 +1,297 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2018 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "doh.h"
|
||||
#include "dynbuf.h"
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#ifndef CURL_DISABLE_DOH
|
||||
#define DNS_PREAMBLE "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00"
|
||||
#define LABEL_TEST "\x04\x74\x65\x73\x74"
|
||||
#define LABEL_HOST "\x04\x68\x6f\x73\x74"
|
||||
#define LABEL_NAME "\x04\x6e\x61\x6d\x65"
|
||||
#define DNSA_TYPE "\x01"
|
||||
#define DNSAAAA_TYPE "\x1c"
|
||||
#define DNSA_EPILOGUE "\x00\x00" DNSA_TYPE "\x00\x01"
|
||||
#define DNSAAAA_EPILOGUE "\x00\x00" DNSAAAA_TYPE "\x00\x01"
|
||||
|
||||
#define DNS_Q1 DNS_PREAMBLE LABEL_TEST LABEL_HOST LABEL_NAME DNSA_EPILOGUE
|
||||
#define DNS_Q2 DNS_PREAMBLE LABEL_TEST LABEL_HOST LABEL_NAME DNSAAAA_EPILOGUE
|
||||
|
||||
struct dohrequest {
|
||||
/* input */
|
||||
const char *name;
|
||||
DNStype type;
|
||||
|
||||
/* output */
|
||||
const char *packet;
|
||||
size_t size;
|
||||
int rc;
|
||||
};
|
||||
|
||||
|
||||
static const struct dohrequest req[] = {
|
||||
{"test.host.name", DNS_TYPE_A, DNS_Q1, sizeof(DNS_Q1)-1, 0 },
|
||||
{"test.host.name", DNS_TYPE_AAAA, DNS_Q2, sizeof(DNS_Q2)-1, 0 },
|
||||
{"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
|
||||
".host.name",
|
||||
DNS_TYPE_AAAA, NULL, 0, DOH_DNS_BAD_LABEL }
|
||||
};
|
||||
|
||||
struct dohresp {
|
||||
/* input */
|
||||
const char *packet;
|
||||
size_t size;
|
||||
DNStype type;
|
||||
|
||||
/* output */
|
||||
int rc;
|
||||
const char *out;
|
||||
};
|
||||
|
||||
#define DNS_FOO_EXAMPLE_COM \
|
||||
"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x00\x03\x66\x6f\x6f" \
|
||||
"\x07\x65\x78\x61\x6d\x70\x6c\x65\x03\x63\x6f\x6d\x00\x00\x01\x00" \
|
||||
"\x01\xc0\x0c\x00\x01\x00\x01\x00\x00\x00\x37\x00\x04\x7f\x00\x00" \
|
||||
"\x01"
|
||||
|
||||
static const char full49[] = DNS_FOO_EXAMPLE_COM;
|
||||
|
||||
static const struct dohresp resp[] = {
|
||||
{"\x00\x00", 2, DNS_TYPE_A, DOH_TOO_SMALL_BUFFER, NULL },
|
||||
{"\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01", 12,
|
||||
DNS_TYPE_A, DOH_DNS_BAD_ID, NULL },
|
||||
{"\x00\x00\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01", 12,
|
||||
DNS_TYPE_A, DOH_DNS_BAD_RCODE, NULL },
|
||||
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x00\x03\x66\x6f\x6f", 16,
|
||||
DNS_TYPE_A, DOH_DNS_OUT_OF_RANGE, NULL },
|
||||
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x00\x03\x66\x6f\x6f\x00", 17,
|
||||
DNS_TYPE_A, DOH_DNS_OUT_OF_RANGE, NULL },
|
||||
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x00\x03\x66\x6f\x6f\x00"
|
||||
"\x00\x01\x00\x01", 21,
|
||||
DNS_TYPE_A, DOH_DNS_OUT_OF_RANGE, NULL },
|
||||
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x00\x03\x66\x6f\x6f\x00"
|
||||
"\x00\x01\x00\x01"
|
||||
"\x04", 18,
|
||||
DNS_TYPE_A, DOH_DNS_OUT_OF_RANGE, NULL },
|
||||
|
||||
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x00\x04\x63\x75\x72"
|
||||
"\x6c\x04\x63\x75\x72\x6c\x00\x00\x05\x00\x01\xc0\x0c\x00\x05\x00"
|
||||
"\x01\x00\x00\x00\x37\x00\x11\x08\x61\x6e\x79\x77\x68\x65\x72\x65"
|
||||
"\x06\x72\x65\x61\x6c\x6c\x79\x00", 56,
|
||||
DNS_TYPE_A, DOH_OK, "anywhere.really "},
|
||||
|
||||
{DNS_FOO_EXAMPLE_COM, 49, DNS_TYPE_A, DOH_OK, "127.0.0.1 "},
|
||||
|
||||
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x00\x04\x61\x61\x61"
|
||||
"\x61\x07\x65\x78\x61\x6d\x70\x6c\x65\x03\x63\x6f\x6d\x00\x00\x1c"
|
||||
"\x00\x01\xc0\x0c\x00\x1c\x00\x01\x00\x00\x00\x37\x00\x10\x20\x20"
|
||||
"\x20\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x20", 62,
|
||||
DNS_TYPE_AAAA, DOH_OK,
|
||||
"2020:2020:0000:0000:0000:0000:0000:2020 " },
|
||||
|
||||
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x00\x04\x63\x75\x72"
|
||||
"\x6c\x04\x63\x75\x72\x6c\x00\x00\x05\x00\x01\xc0\x0c\x00\x05\x00"
|
||||
"\x01\x00\x00\x00\x37\x00"
|
||||
"\x07\x03\x61\x6e\x79\xc0\x27\x00", 46,
|
||||
DNS_TYPE_A, DOH_DNS_LABEL_LOOP, NULL},
|
||||
|
||||
/* packet with NSCOUNT == 1 */
|
||||
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x01\x00\x00\x04\x61\x61\x61"
|
||||
"\x61\x07\x65\x78\x61\x6d\x70\x6c\x65\x03\x63\x6f\x6d\x00\x00\x1c"
|
||||
"\x00\x01\xc0\x0c\x00\x1c\x00\x01\x00\x00\x00\x37\x00\x10\x20\x20"
|
||||
"\x20\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x20"
|
||||
LABEL_TEST LABEL_HOST LABEL_NAME DNSAAAA_EPILOGUE "\x00\x00\x00\x01"
|
||||
"\00\x04\x01\x01\x01\x01", /* RDDATA */
|
||||
|
||||
62 + 30,
|
||||
DNS_TYPE_AAAA, DOH_OK,
|
||||
"2020:2020:0000:0000:0000:0000:0000:2020 " },
|
||||
|
||||
/* packet with ARCOUNT == 1 */
|
||||
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x01\x04\x61\x61\x61"
|
||||
"\x61\x07\x65\x78\x61\x6d\x70\x6c\x65\x03\x63\x6f\x6d\x00\x00\x1c"
|
||||
"\x00\x01\xc0\x0c\x00\x1c\x00\x01\x00\x00\x00\x37\x00\x10\x20\x20"
|
||||
"\x20\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x20"
|
||||
LABEL_TEST LABEL_HOST LABEL_NAME DNSAAAA_EPILOGUE "\x00\x00\x00\x01"
|
||||
"\00\x04\x01\x01\x01\x01", /* RDDATA */
|
||||
|
||||
62 + 30,
|
||||
DNS_TYPE_AAAA, DOH_OK,
|
||||
"2020:2020:0000:0000:0000:0000:0000:2020 " },
|
||||
|
||||
};
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
size_t size = 0;
|
||||
unsigned char buffer[256];
|
||||
size_t i;
|
||||
unsigned char *p;
|
||||
for(i = 0; i < sizeof(req) / sizeof(req[0]); i++) {
|
||||
int rc = doh_encode(req[i].name, req[i].type,
|
||||
buffer, sizeof(buffer), &size);
|
||||
if(rc != req[i].rc) {
|
||||
fprintf(stderr, "req %zu: Expected return code %d got %d\n", i,
|
||||
req[i].rc, rc);
|
||||
return 1;
|
||||
}
|
||||
else if(size != req[i].size) {
|
||||
fprintf(stderr, "req %zu: Expected size %zu got %zu\n", i,
|
||||
req[i].size, size);
|
||||
fprintf(stderr, "DNS encode made: %s\n", hexdump(buffer, size));
|
||||
return 2;
|
||||
}
|
||||
else if(req[i].packet && memcmp(req[i].packet, buffer, size)) {
|
||||
fprintf(stderr, "DNS encode made: %s\n", hexdump(buffer, size));
|
||||
fprintf(stderr, "... instead of: %s\n",
|
||||
hexdump((unsigned char *)req[i].packet, size));
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < sizeof(resp) / sizeof(resp[0]); i++) {
|
||||
struct dohentry d;
|
||||
int rc;
|
||||
char *ptr;
|
||||
size_t len;
|
||||
int u;
|
||||
de_init(&d);
|
||||
rc = doh_decode((const unsigned char *)resp[i].packet, resp[i].size,
|
||||
resp[i].type, &d);
|
||||
if(rc != resp[i].rc) {
|
||||
fprintf(stderr, "resp %zu: Expected return code %d got %d\n", i,
|
||||
resp[i].rc, rc);
|
||||
return 4;
|
||||
}
|
||||
len = sizeof(buffer);
|
||||
ptr = (char *)buffer;
|
||||
for(u = 0; u < d.numaddr; u++) {
|
||||
size_t o;
|
||||
struct dohaddr *a;
|
||||
a = &d.addr[u];
|
||||
if(resp[i].type == DNS_TYPE_A) {
|
||||
p = &a->ip.v4[0];
|
||||
msnprintf(ptr, len, "%u.%u.%u.%u ", p[0], p[1], p[2], p[3]);
|
||||
o = strlen(ptr);
|
||||
len -= o;
|
||||
ptr += o;
|
||||
}
|
||||
else {
|
||||
int j;
|
||||
for(j = 0; j < 16; j += 2) {
|
||||
size_t l;
|
||||
msnprintf(ptr, len, "%s%02x%02x", j?":":"", a->ip.v6[j],
|
||||
a->ip.v6[j + 1]);
|
||||
l = strlen(ptr);
|
||||
len -= l;
|
||||
ptr += l;
|
||||
}
|
||||
msnprintf(ptr, len, " ");
|
||||
len--;
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
for(u = 0; u < d.numcname; u++) {
|
||||
size_t o;
|
||||
msnprintf(ptr, len, "%s ", Curl_dyn_ptr(&d.cname[u]));
|
||||
o = strlen(ptr);
|
||||
len -= o;
|
||||
ptr += o;
|
||||
}
|
||||
de_cleanup(&d);
|
||||
if(resp[i].out && strcmp((char *)buffer, resp[i].out)) {
|
||||
fprintf(stderr, "resp %zu: Expected %s got %s\n", i,
|
||||
resp[i].out, buffer);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
/* pass all sizes into the decoder until full */
|
||||
for(i = 0; i < sizeof(full49)-1; i++) {
|
||||
struct dohentry d;
|
||||
int rc;
|
||||
memset(&d, 0, sizeof(d));
|
||||
rc = doh_decode((const unsigned char *)full49, i, DNS_TYPE_A, &d);
|
||||
if(!rc) {
|
||||
/* none of them should work */
|
||||
fprintf(stderr, "%zu: %d\n", i, rc);
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
/* and try all pieces from the other end of the packet */
|
||||
for(i = 1; i < sizeof(full49); i++) {
|
||||
struct dohentry d;
|
||||
int rc;
|
||||
memset(&d, 0, sizeof(d));
|
||||
rc = doh_decode((const unsigned char *)&full49[i], sizeof(full49)-i-1,
|
||||
DNS_TYPE_A, &d);
|
||||
if(!rc) {
|
||||
/* none of them should work */
|
||||
fprintf(stderr, "2 %zu: %d\n", i, rc);
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
{
|
||||
int rc;
|
||||
struct dohentry d;
|
||||
struct dohaddr *a;
|
||||
memset(&d, 0, sizeof(d));
|
||||
rc = doh_decode((const unsigned char *)full49, sizeof(full49)-1,
|
||||
DNS_TYPE_A, &d);
|
||||
fail_if(d.numaddr != 1, "missing address");
|
||||
a = &d.addr[0];
|
||||
p = &a->ip.v4[0];
|
||||
msnprintf((char *)buffer, sizeof(buffer),
|
||||
"%u.%u.%u.%u", p[0], p[1], p[2], p[3]);
|
||||
if(rc || strcmp((char *)buffer, "127.0.0.1")) {
|
||||
fprintf(stderr, "bad address decoded: %s, rc == %d\n", buffer, rc);
|
||||
return 7;
|
||||
}
|
||||
fail_if(d.numcname, "bad cname counter");
|
||||
}
|
||||
}
|
||||
}
|
||||
UNITTEST_STOP
|
||||
|
||||
#else /* CURL_DISABLE_DOH */
|
||||
UNITTEST_START
|
||||
{
|
||||
return 1; /* nothing to do, just fail */
|
||||
}
|
||||
UNITTEST_STOP
|
||||
|
||||
|
||||
#endif
|
||||
393
Engine/lib/curl/tests/unit/unit1651.c
Normal file
393
Engine/lib/curl/tests/unit/unit1651.c
Normal file
|
|
@ -0,0 +1,393 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2018 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "vtls/x509asn1.h"
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
|
||||
}
|
||||
#if defined(USE_GSKIT) || defined(USE_NSS) || defined(USE_GNUTLS) || \
|
||||
defined(USE_SCHANNEL) || defined(USE_SECTRANSP)
|
||||
|
||||
/* cert captured from gdb when connecting to curl.se on October 26
|
||||
2018 */
|
||||
static unsigned char cert[] = {
|
||||
0x30, 0x82, 0x0F, 0x5B, 0x30, 0x82, 0x0E, 0x43, 0xA0, 0x03, 0x02, 0x01, 0x02,
|
||||
0x02, 0x0C, 0x08, 0x77, 0x99, 0x2C, 0x6B, 0x67, 0xE1, 0x18, 0xD6, 0x66, 0x66,
|
||||
0x9E, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01,
|
||||
0x0B, 0x05, 0x00, 0x30, 0x57, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04,
|
||||
0x06, 0x13, 0x02, 0x42, 0x45, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04,
|
||||
0x0A, 0x13, 0x10, 0x47, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x53, 0x69, 0x67, 0x6E,
|
||||
0x20, 0x6E, 0x76, 0x2D, 0x73, 0x61, 0x31, 0x2D, 0x30, 0x2B, 0x06, 0x03, 0x55,
|
||||
0x04, 0x03, 0x13, 0x24, 0x47, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x53, 0x69, 0x67,
|
||||
0x6E, 0x20, 0x43, 0x6C, 0x6F, 0x75, 0x64, 0x53, 0x53, 0x4C, 0x20, 0x43, 0x41,
|
||||
0x20, 0x2D, 0x20, 0x53, 0x48, 0x41, 0x32, 0x35, 0x36, 0x20, 0x2D, 0x20, 0x47,
|
||||
0x33, 0x30, 0x1E, 0x17, 0x0D, 0x31, 0x38, 0x31, 0x30, 0x32, 0x32, 0x31, 0x37,
|
||||
0x31, 0x38, 0x32, 0x31, 0x5A, 0x17, 0x0D, 0x31, 0x39, 0x30, 0x33, 0x32, 0x31,
|
||||
0x31, 0x33, 0x34, 0x33, 0x34, 0x34, 0x5A, 0x30, 0x77, 0x31, 0x0B, 0x30, 0x09,
|
||||
0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11,
|
||||
0x06, 0x03, 0x55, 0x04, 0x08, 0x0C, 0x0A, 0x43, 0x61, 0x6C, 0x69, 0x66, 0x6F,
|
||||
0x72, 0x6E, 0x69, 0x61, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x07,
|
||||
0x0C, 0x0D, 0x53, 0x61, 0x6E, 0x20, 0x46, 0x72, 0x61, 0x6E, 0x63, 0x69, 0x73,
|
||||
0x63, 0x6F, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x0C,
|
||||
0x46, 0x61, 0x73, 0x74, 0x6C, 0x79, 0x2C, 0x20, 0x49, 0x6E, 0x63, 0x2E, 0x31,
|
||||
0x24, 0x30, 0x22, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x1B, 0x6A, 0x32, 0x2E,
|
||||
0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2E, 0x67, 0x6C, 0x6F, 0x62, 0x61, 0x6C,
|
||||
0x2E, 0x66, 0x61, 0x73, 0x74, 0x6C, 0x79, 0x2E, 0x6E, 0x65, 0x74, 0x30, 0x82,
|
||||
0x01, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01,
|
||||
0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0F, 0x00, 0x30, 0x82, 0x01, 0x0A,
|
||||
0x02, 0x82, 0x01, 0x01, 0x00, 0xC2, 0x72, 0xA2, 0x4A, 0xEF, 0x26, 0x42, 0xD7,
|
||||
0x85, 0x74, 0xC9, 0xB4, 0x9F, 0xE3, 0x31, 0xD1, 0x40, 0x77, 0xC9, 0x4B, 0x4D,
|
||||
0xFE, 0xC8, 0x75, 0xF3, 0x32, 0x76, 0xAD, 0xF9, 0x08, 0x22, 0x9E, 0xFA, 0x2F,
|
||||
0xFE, 0xEC, 0x6C, 0xC4, 0xF5, 0x1F, 0x70, 0xC9, 0x8F, 0x07, 0x48, 0x31, 0xAD,
|
||||
0x75, 0x18, 0xFC, 0x06, 0x5A, 0x4F, 0xDD, 0xFD, 0x05, 0x39, 0x6F, 0x22, 0xF9,
|
||||
0xAD, 0x62, 0x1A, 0x9E, 0xA6, 0x16, 0x48, 0x75, 0x8F, 0xB8, 0x07, 0x18, 0x25,
|
||||
0x1A, 0x87, 0x30, 0xB0, 0x3C, 0x6F, 0xE0, 0x9D, 0x90, 0x63, 0x2A, 0x16, 0x1F,
|
||||
0x0D, 0x10, 0xFC, 0x06, 0x7E, 0xEA, 0x51, 0xE2, 0xB0, 0x6D, 0x42, 0x4C, 0x2C,
|
||||
0x59, 0xF4, 0x6B, 0x99, 0x3E, 0x82, 0x1D, 0x08, 0x04, 0x2F, 0xA0, 0x63, 0x3C,
|
||||
0xAA, 0x0E, 0xE1, 0x5D, 0x67, 0x2D, 0xB3, 0xF4, 0x15, 0xD6, 0x16, 0x4E, 0xAA,
|
||||
0x91, 0x45, 0x6B, 0xC5, 0xA6, 0xED, 0x83, 0xAF, 0xF1, 0xD7, 0x42, 0x5E, 0x9B,
|
||||
0xC8, 0x39, 0x0C, 0x06, 0x76, 0x7A, 0xB8, 0x3E, 0x16, 0x70, 0xF5, 0xEB, 0x8B,
|
||||
0x33, 0x5A, 0xA9, 0x03, 0xED, 0x79, 0x0E, 0xAD, 0xBB, 0xC4, 0xF8, 0xDA, 0x93,
|
||||
0x53, 0x2A, 0xC4, 0xC9, 0x1A, 0xD1, 0xC3, 0x44, 0xD7, 0xC6, 0xD0, 0xC6, 0xAC,
|
||||
0x13, 0xE3, 0xB5, 0x73, 0x3A, 0xDF, 0x54, 0x15, 0xFB, 0xB4, 0x6B, 0x36, 0x39,
|
||||
0x18, 0xB5, 0x61, 0x12, 0xF0, 0x37, 0xAB, 0x81, 0x5F, 0x0C, 0xE7, 0xDF, 0xC1,
|
||||
0xC5, 0x5E, 0x99, 0x67, 0x85, 0xFF, 0xAD, 0xD6, 0x82, 0x09, 0x1F, 0x27, 0xE5,
|
||||
0x32, 0x52, 0x18, 0xEC, 0x35, 0x2F, 0x6C, 0xC9, 0xE6, 0x87, 0xCE, 0x30, 0xF6,
|
||||
0xDA, 0x04, 0x3F, 0xA5, 0x8A, 0x0C, 0xAE, 0x5B, 0xB0, 0xEC, 0x29, 0x9B, 0xEE,
|
||||
0x8F, 0x52, 0x1E, 0xE2, 0x56, 0x19, 0x45, 0x80, 0x3C, 0x02, 0x57, 0x5C, 0x52,
|
||||
0xD9, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x82, 0x0C, 0x05, 0x30, 0x82, 0x0C,
|
||||
0x01, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x1D, 0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04,
|
||||
0x03, 0x02, 0x05, 0xA0, 0x30, 0x81, 0x8A, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05,
|
||||
0x05, 0x07, 0x01, 0x01, 0x04, 0x7E, 0x30, 0x7C, 0x30, 0x42, 0x06, 0x08, 0x2B,
|
||||
0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x02, 0x86, 0x36, 0x68, 0x74, 0x74, 0x70,
|
||||
0x3A, 0x2F, 0x2F, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x2E, 0x67, 0x6C, 0x6F,
|
||||
0x62, 0x61, 0x6C, 0x73, 0x69, 0x67, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x2F, 0x63,
|
||||
0x61, 0x63, 0x65, 0x72, 0x74, 0x2F, 0x63, 0x6C, 0x6F, 0x75, 0x64, 0x73, 0x73,
|
||||
0x6C, 0x73, 0x68, 0x61, 0x32, 0x67, 0x33, 0x2E, 0x63, 0x72, 0x74, 0x30, 0x36,
|
||||
0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01, 0x86, 0x2A, 0x68,
|
||||
0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x6F, 0x63, 0x73, 0x70, 0x32, 0x2E, 0x67,
|
||||
0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x73, 0x69, 0x67, 0x6E, 0x2E, 0x63, 0x6F, 0x6D,
|
||||
0x2F, 0x63, 0x6C, 0x6F, 0x75, 0x64, 0x73, 0x73, 0x6C, 0x73, 0x68, 0x61, 0x32,
|
||||
0x67, 0x33, 0x30, 0x56, 0x06, 0x03, 0x55, 0x1D, 0x20, 0x04, 0x4F, 0x30, 0x4D,
|
||||
0x30, 0x41, 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0xA0, 0x32, 0x01, 0x14,
|
||||
0x30, 0x34, 0x30, 0x32, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x02,
|
||||
0x01, 0x16, 0x26, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3A, 0x2F, 0x2F, 0x77, 0x77,
|
||||
0x77, 0x2E, 0x67, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x73, 0x69, 0x67, 0x6E, 0x2E,
|
||||
0x63, 0x6F, 0x6D, 0x2F, 0x72, 0x65, 0x70, 0x6F, 0x73, 0x69, 0x74, 0x6F, 0x72,
|
||||
0x79, 0x2F, 0x30, 0x08, 0x06, 0x06, 0x67, 0x81, 0x0C, 0x01, 0x02, 0x02, 0x30,
|
||||
0x09, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x82, 0x09,
|
||||
0x96, 0x06, 0x03, 0x55, 0x1D, 0x11, 0x04, 0x82, 0x09, 0x8D, 0x30, 0x82, 0x09,
|
||||
0x89, 0x82, 0x1B, 0x6A, 0x32, 0x2E, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2E,
|
||||
0x67, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x2E, 0x66, 0x61, 0x73, 0x74, 0x6C, 0x79,
|
||||
0x2E, 0x6E, 0x65, 0x74, 0x82, 0x0D, 0x2A, 0x2E, 0x61, 0x32, 0x70, 0x72, 0x65,
|
||||
0x73, 0x73, 0x65, 0x2E, 0x66, 0x72, 0x82, 0x19, 0x2A, 0x2E, 0x61, 0x64, 0x76,
|
||||
0x65, 0x6E, 0x74, 0x69, 0x73, 0x74, 0x62, 0x6F, 0x6F, 0x6B, 0x63, 0x65, 0x6E,
|
||||
0x74, 0x65, 0x72, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x2A, 0x2E, 0x61, 0x70,
|
||||
0x69, 0x2E, 0x6C, 0x6F, 0x6C, 0x65, 0x73, 0x70, 0x6F, 0x72, 0x74, 0x73, 0x2E,
|
||||
0x63, 0x6F, 0x6D, 0x82, 0x0C, 0x2A, 0x2E, 0x62, 0x61, 0x61, 0x74, 0x63, 0x68,
|
||||
0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x17, 0x2A, 0x2E, 0x62, 0x69, 0x6F, 0x74, 0x65,
|
||||
0x63, 0x68, 0x77, 0x65, 0x65, 0x6B, 0x62, 0x6F, 0x73, 0x74, 0x6F, 0x6E, 0x2E,
|
||||
0x63, 0x6F, 0x6D, 0x82, 0x10, 0x2A, 0x2E, 0x62, 0x6F, 0x78, 0x6F, 0x66, 0x73,
|
||||
0x74, 0x79, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0C, 0x2A, 0x2E, 0x63,
|
||||
0x61, 0x73, 0x70, 0x65, 0x72, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x11, 0x2A, 0x2E,
|
||||
0x63, 0x68, 0x61, 0x6B, 0x72, 0x61, 0x6C, 0x69, 0x6E, 0x75, 0x78, 0x2E, 0x6F,
|
||||
0x72, 0x67, 0x82, 0x18, 0x2A, 0x2E, 0x63, 0x6F, 0x6E, 0x76, 0x65, 0x72, 0x74,
|
||||
0x2E, 0x64, 0x73, 0x2E, 0x76, 0x65, 0x72, 0x69, 0x7A, 0x6F, 0x6E, 0x2E, 0x63,
|
||||
0x6F, 0x6D, 0x82, 0x15, 0x2A, 0x2E, 0x64, 0x65, 0x76, 0x73, 0x70, 0x61, 0x63,
|
||||
0x65, 0x73, 0x68, 0x69, 0x70, 0x2E, 0x63, 0x6F, 0x6D, 0x2E, 0x61, 0x75, 0x82,
|
||||
0x1B, 0x2A, 0x2E, 0x64, 0x65, 0x76, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x68,
|
||||
0x69, 0x70, 0x69, 0x6E, 0x76, 0x65, 0x73, 0x74, 0x2E, 0x63, 0x6F, 0x6D, 0x2E,
|
||||
0x61, 0x75, 0x82, 0x0A, 0x2A, 0x2E, 0x65, 0x63, 0x68, 0x6C, 0x2E, 0x63, 0x6F,
|
||||
0x6D, 0x82, 0x0F, 0x2A, 0x2E, 0x66, 0x69, 0x6C, 0x65, 0x73, 0x74, 0x61, 0x63,
|
||||
0x6B, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16, 0x2A, 0x2E, 0x66, 0x69, 0x6C, 0x65,
|
||||
0x73, 0x74, 0x61, 0x63, 0x6B, 0x2E, 0x6F, 0x6E, 0x65, 0x6D, 0x6F, 0x62, 0x2E,
|
||||
0x63, 0x6F, 0x6D, 0x82, 0x0D, 0x2A, 0x2E, 0x66, 0x69, 0x73, 0x2D, 0x73, 0x6B,
|
||||
0x69, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0C, 0x2A, 0x2E, 0x66, 0x69, 0x73, 0x73,
|
||||
0x6B, 0x69, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x2A, 0x2E, 0x66, 0x70, 0x2E,
|
||||
0x62, 0x72, 0x61, 0x6E, 0x64, 0x66, 0x6F, 0x6C, 0x64, 0x65, 0x72, 0x2E, 0x63,
|
||||
0x6F, 0x6D, 0x82, 0x0F, 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x65, 0x6E, 0x70, 0x6C,
|
||||
0x75, 0x67, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0E, 0x2A, 0x2E, 0x66, 0x73, 0x2E,
|
||||
0x65, 0x6E, 0x70, 0x6C, 0x75, 0x67, 0x2E, 0x69, 0x6E, 0x82, 0x10, 0x2A, 0x2E,
|
||||
0x66, 0x73, 0x2E, 0x68, 0x65, 0x72, 0x6F, 0x69, 0x6E, 0x65, 0x2E, 0x63, 0x6F,
|
||||
0x6D, 0x82, 0x18, 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x6C, 0x65, 0x61, 0x72, 0x6E,
|
||||
0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F,
|
||||
0x6D, 0x82, 0x18, 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x6C, 0x6F, 0x63, 0x61, 0x6C,
|
||||
0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F,
|
||||
0x6D, 0x82, 0x12, 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x6D, 0x69, 0x6E, 0x64, 0x66,
|
||||
0x6C, 0x61, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16, 0x2A, 0x2E, 0x66,
|
||||
0x73, 0x2E, 0x6F, 0x70, 0x73, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63,
|
||||
0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x10, 0x2A, 0x2E, 0x66, 0x73, 0x2E,
|
||||
0x70, 0x69, 0x78, 0x76, 0x61, 0x6E, 0x61, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x15,
|
||||
0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x71, 0x61, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F,
|
||||
0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x17, 0x2A, 0x2E, 0x66,
|
||||
0x73, 0x2E, 0x74, 0x65, 0x73, 0x74, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E,
|
||||
0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x09, 0x2A, 0x2E, 0x68, 0x61,
|
||||
0x78, 0x78, 0x2E, 0x73, 0x65, 0x82, 0x0D, 0x2A, 0x2E, 0x68, 0x6F, 0x6D, 0x65,
|
||||
0x61, 0x77, 0x61, 0x79, 0x2E, 0x6C, 0x6B, 0x82, 0x0F, 0x2A, 0x2E, 0x69, 0x64,
|
||||
0x61, 0x74, 0x61, 0x6C, 0x69, 0x6E, 0x6B, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16,
|
||||
0x2A, 0x2E, 0x69, 0x64, 0x61, 0x74, 0x61, 0x6C, 0x69, 0x6E, 0x6B, 0x6D, 0x61,
|
||||
0x65, 0x73, 0x74, 0x72, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x11, 0x2A, 0x2E,
|
||||
0x69, 0x6D, 0x67, 0x2D, 0x74, 0x61, 0x62, 0x6F, 0x6F, 0x6C, 0x61, 0x2E, 0x63,
|
||||
0x6F, 0x6D, 0x82, 0x0F, 0x2A, 0x2E, 0x6A, 0x75, 0x6C, 0x69, 0x61, 0x6C, 0x61,
|
||||
0x6E, 0x67, 0x2E, 0x6F, 0x72, 0x67, 0x82, 0x10, 0x2A, 0x2E, 0x6B, 0x69, 0x6E,
|
||||
0x64, 0x73, 0x6E, 0x61, 0x63, 0x6B, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x10,
|
||||
0x2A, 0x2E, 0x6B, 0x73, 0x73, 0x76, 0x61, 0x6E, 0x69, 0x6C, 0x6C, 0x61, 0x2E,
|
||||
0x63, 0x6F, 0x6D, 0x82, 0x0E, 0x2A, 0x2E, 0x6B, 0x73, 0x74, 0x63, 0x6F, 0x72,
|
||||
0x72, 0x61, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x10, 0x2A, 0x2E, 0x6B, 0x73, 0x74,
|
||||
0x76, 0x61, 0x6E, 0x69, 0x6C, 0x6C, 0x61, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0C,
|
||||
0x2A, 0x2E, 0x6E, 0x65, 0x77, 0x73, 0x31, 0x32, 0x2E, 0x63, 0x6F, 0x6D, 0x82,
|
||||
0x1B, 0x2A, 0x2E, 0x70, 0x61, 0x72, 0x74, 0x69, 0x64, 0x65, 0x6E, 0x74, 0x69,
|
||||
0x66, 0x69, 0x65, 0x72, 0x2E, 0x73, 0x77, 0x69, 0x73, 0x63, 0x6F, 0x2E, 0x63,
|
||||
0x6F, 0x6D, 0x82, 0x13, 0x2A, 0x2E, 0x73, 0x68, 0x6F, 0x70, 0x72, 0x61, 0x63,
|
||||
0x68, 0x65, 0x6C, 0x7A, 0x6F, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0A, 0x2A,
|
||||
0x2E, 0x74, 0x61, 0x73, 0x74, 0x79, 0x2E, 0x63, 0x6F, 0x82, 0x0C, 0x2A, 0x2E,
|
||||
0x74, 0x65, 0x64, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x15, 0x2A,
|
||||
0x2E, 0x75, 0x70, 0x6C, 0x6F, 0x61, 0x64, 0x73, 0x2E, 0x66, 0x6F, 0x6C, 0x69,
|
||||
0x6F, 0x68, 0x64, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x2A, 0x2E, 0x76, 0x6F,
|
||||
0x75, 0x63, 0x68, 0x65, 0x72, 0x63, 0x6F, 0x64, 0x65, 0x73, 0x2E, 0x63, 0x6F,
|
||||
0x2E, 0x75, 0x6B, 0x82, 0x0D, 0x2A, 0x2E, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65,
|
||||
0x72, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0D, 0x61, 0x2E, 0x69, 0x63, 0x61, 0x6E,
|
||||
0x76, 0x61, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0B, 0x61, 0x32, 0x70, 0x72,
|
||||
0x65, 0x73, 0x73, 0x65, 0x2E, 0x66, 0x72, 0x82, 0x17, 0x61, 0x64, 0x76, 0x65,
|
||||
0x6E, 0x74, 0x69, 0x73, 0x74, 0x62, 0x6F, 0x6F, 0x6B, 0x63, 0x65, 0x6E, 0x74,
|
||||
0x65, 0x72, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x11, 0x61, 0x70, 0x69, 0x2D, 0x6D,
|
||||
0x65, 0x72, 0x72, 0x79, 0x6A, 0x61, 0x6E, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82,
|
||||
0x12, 0x61, 0x70, 0x69, 0x73, 0x2E, 0x69, 0x64, 0x61, 0x74, 0x61, 0x6C, 0x69,
|
||||
0x76, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0F, 0x61, 0x70, 0x70, 0x2D, 0x61,
|
||||
0x70, 0x69, 0x2E, 0x74, 0x65, 0x64, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x12, 0x61,
|
||||
0x70, 0x70, 0x2E, 0x62, 0x69, 0x72, 0x63, 0x68, 0x62, 0x6F, 0x78, 0x2E, 0x63,
|
||||
0x6F, 0x2E, 0x75, 0x6B, 0x82, 0x0F, 0x61, 0x70, 0x70, 0x2E, 0x62, 0x69, 0x72,
|
||||
0x63, 0x68, 0x62, 0x6F, 0x78, 0x2E, 0x65, 0x73, 0x82, 0x1A, 0x61, 0x70, 0x70,
|
||||
0x2E, 0x73, 0x74, 0x61, 0x67, 0x69, 0x6E, 0x67, 0x2E, 0x62, 0x69, 0x72, 0x63,
|
||||
0x68, 0x62, 0x6F, 0x78, 0x2E, 0x63, 0x6F, 0x2E, 0x75, 0x6B, 0x82, 0x17, 0x61,
|
||||
0x70, 0x70, 0x2E, 0x73, 0x74, 0x61, 0x67, 0x69, 0x6E, 0x67, 0x2E, 0x62, 0x69,
|
||||
0x72, 0x63, 0x68, 0x62, 0x6F, 0x78, 0x2E, 0x65, 0x73, 0x82, 0x0A, 0x62, 0x61,
|
||||
0x61, 0x74, 0x63, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x13, 0x62, 0x65, 0x72,
|
||||
0x6E, 0x61, 0x72, 0x64, 0x63, 0x6F, 0x6E, 0x74, 0x72, 0x6F, 0x6C, 0x73, 0x2E,
|
||||
0x63, 0x6F, 0x6D, 0x82, 0x15, 0x62, 0x69, 0x6F, 0x74, 0x65, 0x63, 0x68, 0x77,
|
||||
0x65, 0x65, 0x6B, 0x62, 0x6F, 0x73, 0x74, 0x6F, 0x6E, 0x2E, 0x63, 0x6F, 0x6D,
|
||||
0x82, 0x0E, 0x62, 0x6F, 0x78, 0x6F, 0x66, 0x73, 0x74, 0x79, 0x6C, 0x65, 0x2E,
|
||||
0x63, 0x6F, 0x6D, 0x82, 0x0A, 0x63, 0x61, 0x73, 0x70, 0x65, 0x72, 0x2E, 0x63,
|
||||
0x6F, 0x6D, 0x82, 0x0D, 0x63, 0x64, 0x6E, 0x2E, 0x69, 0x72, 0x73, 0x64, 0x6E,
|
||||
0x2E, 0x6E, 0x65, 0x74, 0x82, 0x0F, 0x63, 0x68, 0x61, 0x6B, 0x72, 0x61, 0x6C,
|
||||
0x69, 0x6E, 0x75, 0x78, 0x2E, 0x6F, 0x72, 0x67, 0x82, 0x13, 0x64, 0x65, 0x76,
|
||||
0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x68, 0x69, 0x70, 0x2E, 0x63, 0x6F, 0x6D,
|
||||
0x2E, 0x61, 0x75, 0x82, 0x0B, 0x64, 0x69, 0x67, 0x69, 0x64, 0x61, 0x79, 0x2E,
|
||||
0x63, 0x6F, 0x6D, 0x82, 0x22, 0x64, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6C, 0x4C,
|
||||
0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x2E, 0x62, 0x65, 0x72, 0x6E, 0x61, 0x72,
|
||||
0x64, 0x63, 0x6F, 0x6E, 0x74, 0x72, 0x6F, 0x6C, 0x73, 0x2E, 0x63, 0x6F, 0x6D,
|
||||
0x82, 0x14, 0x64, 0x72, 0x77, 0x70, 0x2E, 0x73, 0x74, 0x61, 0x67, 0x69, 0x6E,
|
||||
0x67, 0x2E, 0x6D, 0x6F, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x08, 0x65, 0x63,
|
||||
0x68, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x66, 0x69, 0x6C, 0x65, 0x73,
|
||||
0x74, 0x61, 0x63, 0x6B, 0x2E, 0x6F, 0x6E, 0x65, 0x6D, 0x6F, 0x62, 0x2E, 0x63,
|
||||
0x6F, 0x6D, 0x82, 0x0D, 0x66, 0x73, 0x2E, 0x65, 0x6E, 0x70, 0x6C, 0x75, 0x67,
|
||||
0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16, 0x66, 0x73, 0x2E, 0x6C, 0x65, 0x61, 0x72,
|
||||
0x6E, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63,
|
||||
0x6F, 0x6D, 0x82, 0x16, 0x66, 0x73, 0x2E, 0x6C, 0x6F, 0x63, 0x61, 0x6C, 0x7A,
|
||||
0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D,
|
||||
0x82, 0x14, 0x66, 0x73, 0x2E, 0x6F, 0x70, 0x73, 0x7A, 0x69, 0x6C, 0x6C, 0x69,
|
||||
0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x13, 0x66, 0x73,
|
||||
0x2E, 0x71, 0x61, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E,
|
||||
0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x15, 0x66, 0x73, 0x2E, 0x74, 0x65, 0x73, 0x74,
|
||||
0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F,
|
||||
0x6D, 0x82, 0x0B, 0x68, 0x6F, 0x6D, 0x65, 0x61, 0x77, 0x61, 0x79, 0x2E, 0x6C,
|
||||
0x6B, 0x82, 0x12, 0x69, 0x6D, 0x67, 0x2E, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65,
|
||||
0x72, 0x6D, 0x61, 0x69, 0x6C, 0x2E, 0x69, 0x6F, 0x82, 0x0E, 0x6B, 0x69, 0x6E,
|
||||
0x64, 0x73, 0x6E, 0x61, 0x63, 0x6B, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0E,
|
||||
0x6B, 0x73, 0x73, 0x76, 0x61, 0x6E, 0x69, 0x6C, 0x6C, 0x61, 0x2E, 0x63, 0x6F,
|
||||
0x6D, 0x82, 0x0C, 0x6B, 0x73, 0x74, 0x63, 0x6F, 0x72, 0x72, 0x61, 0x2E, 0x63,
|
||||
0x6F, 0x6D, 0x82, 0x0D, 0x6D, 0x65, 0x6E, 0x75, 0x2E, 0x74, 0x72, 0x65, 0x65,
|
||||
0x7A, 0x2E, 0x69, 0x6F, 0x82, 0x17, 0x6D, 0x6F, 0x62, 0x69, 0x6C, 0x65, 0x61,
|
||||
0x70, 0x69, 0x2E, 0x69, 0x64, 0x61, 0x74, 0x61, 0x6C, 0x69, 0x6E, 0x6B, 0x2E,
|
||||
0x63, 0x6F, 0x6D, 0x82, 0x0A, 0x6E, 0x65, 0x77, 0x73, 0x31, 0x32, 0x2E, 0x63,
|
||||
0x6F, 0x6D, 0x82, 0x0B, 0x6F, 0x6D, 0x6E, 0x69, 0x67, 0x6F, 0x6E, 0x2E, 0x63,
|
||||
0x6F, 0x6D, 0x82, 0x0E, 0x6F, 0x72, 0x65, 0x69, 0x6C, 0x6C, 0x79, 0x2E, 0x72,
|
||||
0x65, 0x76, 0x69, 0x65, 0x77, 0x82, 0x11, 0x70, 0x6F, 0x70, 0x79, 0x6F, 0x75,
|
||||
0x72, 0x62, 0x75, 0x62, 0x62, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x18,
|
||||
0x70, 0x72, 0x6F, 0x64, 0x2E, 0x62, 0x65, 0x72, 0x6E, 0x61, 0x72, 0x64, 0x63,
|
||||
0x6F, 0x6E, 0x74, 0x72, 0x6F, 0x6C, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x18,
|
||||
0x72, 0x65, 0x6C, 0x65, 0x61, 0x73, 0x65, 0x2D, 0x70, 0x72, 0x69, 0x6D, 0x65,
|
||||
0x2E, 0x73, 0x70, 0x6F, 0x6B, 0x65, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x19,
|
||||
0x72, 0x65, 0x70, 0x6F, 0x73, 0x69, 0x74, 0x6F, 0x72, 0x69, 0x65, 0x73, 0x2E,
|
||||
0x73, 0x65, 0x6E, 0x73, 0x75, 0x61, 0x70, 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x82,
|
||||
0x0C, 0x72, 0x6C, 0x2E, 0x74, 0x61, 0x6C, 0x69, 0x73, 0x2E, 0x63, 0x6F, 0x6D,
|
||||
0x82, 0x11, 0x73, 0x68, 0x6F, 0x70, 0x72, 0x61, 0x63, 0x68, 0x65, 0x6C, 0x7A,
|
||||
0x6F, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0F, 0x73, 0x74, 0x61, 0x67, 0x69,
|
||||
0x6E, 0x67, 0x2E, 0x6D, 0x6F, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x73,
|
||||
0x74, 0x61, 0x74, 0x69, 0x63, 0x2E, 0x70, 0x6C, 0x75, 0x6D, 0x63, 0x61, 0x63,
|
||||
0x68, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x73, 0x74, 0x61, 0x79, 0x69,
|
||||
0x6E, 0x67, 0x61, 0x6C, 0x69, 0x76, 0x65, 0x2E, 0x6D, 0x73, 0x66, 0x2E, 0x6F,
|
||||
0x72, 0x67, 0x82, 0x08, 0x74, 0x61, 0x73, 0x74, 0x79, 0x2E, 0x63, 0x6F, 0x82,
|
||||
0x0C, 0x74, 0x6F, 0x70, 0x73, 0x70, 0x65, 0x65, 0x64, 0x2E, 0x63, 0x6F, 0x6D,
|
||||
0x82, 0x13, 0x75, 0x70, 0x6C, 0x6F, 0x61, 0x64, 0x73, 0x2E, 0x66, 0x6F, 0x6C,
|
||||
0x69, 0x6F, 0x68, 0x64, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x1A, 0x75, 0x73, 0x2D,
|
||||
0x65, 0x75, 0x2E, 0x66, 0x69, 0x6C, 0x65, 0x73, 0x74, 0x61, 0x63, 0x6B, 0x63,
|
||||
0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x74, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x12, 0x76,
|
||||
0x6F, 0x75, 0x63, 0x68, 0x65, 0x72, 0x63, 0x6F, 0x64, 0x65, 0x73, 0x2E, 0x63,
|
||||
0x6F, 0x2E, 0x75, 0x6B, 0x82, 0x0B, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72,
|
||||
0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x13, 0x77, 0x6F, 0x6D, 0x65, 0x6E, 0x73, 0x68,
|
||||
0x65, 0x61, 0x6C, 0x74, 0x68, 0x2D, 0x6A, 0x70, 0x2E, 0x63, 0x6F, 0x6D, 0x82,
|
||||
0x19, 0x77, 0x6F, 0x72, 0x6B, 0x65, 0x72, 0x62, 0x65, 0x65, 0x2E, 0x73, 0x74,
|
||||
0x61, 0x67, 0x69, 0x6E, 0x67, 0x2E, 0x6D, 0x6F, 0x6F, 0x2E, 0x63, 0x6F, 0x6D,
|
||||
0x82, 0x0A, 0x77, 0x77, 0x77, 0x2E, 0x61, 0x67, 0x66, 0x2E, 0x64, 0x6B, 0x82,
|
||||
0x14, 0x77, 0x77, 0x77, 0x2E, 0x61, 0x76, 0x65, 0x6E, 0x69, 0x72, 0x2D, 0x73,
|
||||
0x75, 0x69, 0x73, 0x73, 0x65, 0x2E, 0x63, 0x68, 0x82, 0x11, 0x77, 0x77, 0x77,
|
||||
0x2E, 0x63, 0x61, 0x6E, 0x73, 0x74, 0x61, 0x72, 0x2E, 0x63, 0x6F, 0x2E, 0x6E,
|
||||
0x7A, 0x82, 0x15, 0x77, 0x77, 0x77, 0x2E, 0x63, 0x61, 0x6E, 0x73, 0x74, 0x61,
|
||||
0x72, 0x62, 0x6C, 0x75, 0x65, 0x2E, 0x63, 0x6F, 0x2E, 0x6E, 0x7A, 0x82, 0x16,
|
||||
0x77, 0x77, 0x77, 0x2E, 0x63, 0x61, 0x6E, 0x73, 0x74, 0x61, 0x72, 0x62, 0x6C,
|
||||
0x75, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x2E, 0x61, 0x75, 0x82, 0x1D, 0x77, 0x77,
|
||||
0x77, 0x2E, 0x63, 0x68, 0x61, 0x6D, 0x70, 0x69, 0x6F, 0x6E, 0x73, 0x68, 0x6F,
|
||||
0x63, 0x6B, 0x65, 0x79, 0x6C, 0x65, 0x61, 0x67, 0x75, 0x65, 0x2E, 0x6E, 0x65,
|
||||
0x74, 0x82, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x65, 0x78, 0x74, 0x65, 0x72, 0x72,
|
||||
0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0C, 0x77, 0x77, 0x77, 0x2E, 0x65, 0x7A,
|
||||
0x75, 0x70, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0B, 0x77, 0x77, 0x77, 0x2E, 0x65,
|
||||
0x7A, 0x75, 0x70, 0x2E, 0x64, 0x65, 0x82, 0x0B, 0x77, 0x77, 0x77, 0x2E, 0x65,
|
||||
0x7A, 0x75, 0x70, 0x2E, 0x65, 0x75, 0x82, 0x0B, 0x77, 0x77, 0x77, 0x2E, 0x65,
|
||||
0x7A, 0x75, 0x70, 0x2E, 0x6E, 0x6C, 0x82, 0x11, 0x77, 0x77, 0x77, 0x2E, 0x66,
|
||||
0x72, 0x61, 0x6E, 0x6B, 0x62, 0x6F, 0x64, 0x79, 0x2E, 0x63, 0x6F, 0x6D, 0x82,
|
||||
0x0D, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6C, 0x6F, 0x73, 0x73, 0x79, 0x2E, 0x63,
|
||||
0x6F, 0x82, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6F, 0x6C, 0x64, 0x63, 0x75,
|
||||
0x70, 0x2E, 0x6F, 0x72, 0x67, 0x82, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x69, 0x63,
|
||||
0x61, 0x6E, 0x76, 0x61, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0D, 0x77, 0x77,
|
||||
0x77, 0x2E, 0x6D, 0x6F, 0x6E, 0x69, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16,
|
||||
0x77, 0x77, 0x77, 0x2E, 0x6F, 0x64, 0x65, 0x6E, 0x73, 0x65, 0x2D, 0x6D, 0x61,
|
||||
0x72, 0x63, 0x69, 0x70, 0x61, 0x6E, 0x2E, 0x64, 0x6B, 0x82, 0x15, 0x77, 0x77,
|
||||
0x77, 0x2E, 0x6F, 0x6E, 0x65, 0x63, 0x6C, 0x69, 0x63, 0x6B, 0x64, 0x72, 0x69,
|
||||
0x76, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x12, 0x77, 0x77, 0x77, 0x2E, 0x6F,
|
||||
0x72, 0x65, 0x69, 0x6C, 0x6C, 0x79, 0x2E, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77,
|
||||
0x82, 0x15, 0x77, 0x77, 0x77, 0x2E, 0x70, 0x6F, 0x70, 0x79, 0x6F, 0x75, 0x72,
|
||||
0x62, 0x75, 0x62, 0x62, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0E, 0x77,
|
||||
0x77, 0x77, 0x2E, 0x72, 0x61, 0x77, 0x6E, 0x65, 0x74, 0x2E, 0x63, 0x6F, 0x6D,
|
||||
0x82, 0x0E, 0x77, 0x77, 0x77, 0x2E, 0x73, 0x70, 0x6F, 0x6B, 0x65, 0x6F, 0x2E,
|
||||
0x63, 0x6F, 0x6D, 0x82, 0x10, 0x77, 0x77, 0x77, 0x2E, 0x74, 0x65, 0x61, 0x72,
|
||||
0x73, 0x68, 0x65, 0x65, 0x74, 0x2E, 0x63, 0x6F, 0x82, 0x10, 0x77, 0x77, 0x77,
|
||||
0x2E, 0x74, 0x6F, 0x70, 0x73, 0x70, 0x65, 0x65, 0x64, 0x2E, 0x63, 0x6F, 0x6D,
|
||||
0x82, 0x16, 0x77, 0x77, 0x77, 0x2E, 0x77, 0x68, 0x69, 0x74, 0x65, 0x6B, 0x65,
|
||||
0x79, 0x76, 0x69, 0x6C, 0x6C, 0x61, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x30, 0x1D,
|
||||
0x06, 0x03, 0x55, 0x1D, 0x25, 0x04, 0x16, 0x30, 0x14, 0x06, 0x08, 0x2B, 0x06,
|
||||
0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05,
|
||||
0x07, 0x03, 0x02, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, 0x04, 0x16, 0x04,
|
||||
0x14, 0xA8, 0x29, 0xFD, 0xA9, 0xA5, 0x1A, 0x1C, 0x37, 0x0B, 0x20, 0x3B, 0x98,
|
||||
0xB7, 0x25, 0x39, 0xCC, 0xE5, 0x2F, 0xF4, 0x94, 0x30, 0x1F, 0x06, 0x03, 0x55,
|
||||
0x1D, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xA9, 0x2B, 0x87, 0xE1, 0xCE,
|
||||
0x24, 0x47, 0x3B, 0x1B, 0xBF, 0xCF, 0x85, 0x37, 0x02, 0x55, 0x9D, 0x0D, 0x94,
|
||||
0x58, 0xE6, 0x30, 0x82, 0x01, 0x04, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01,
|
||||
0xD6, 0x79, 0x02, 0x04, 0x02, 0x04, 0x81, 0xF5, 0x04, 0x81, 0xF2, 0x00, 0xF0,
|
||||
0x00, 0x77, 0x00, 0xA4, 0xB9, 0x09, 0x90, 0xB4, 0x18, 0x58, 0x14, 0x87, 0xBB,
|
||||
0x13, 0xA2, 0xCC, 0x67, 0x70, 0x0A, 0x3C, 0x35, 0x98, 0x04, 0xF9, 0x1B, 0xDF,
|
||||
0xB8, 0xE3, 0x77, 0xCD, 0x0E, 0xC8, 0x0D, 0xDC, 0x10, 0x00, 0x00, 0x01, 0x66,
|
||||
0x9C, 0xC8, 0xE7, 0x38, 0x00, 0x00, 0x04, 0x03, 0x00, 0x48, 0x30, 0x46, 0x02,
|
||||
0x21, 0x00, 0xD9, 0x58, 0x6E, 0xFC, 0x4C, 0x3C, 0xAF, 0xF9, 0x5B, 0x7F, 0xDA,
|
||||
0x54, 0x95, 0xAF, 0xCF, 0xB3, 0x57, 0xB9, 0x56, 0x2C, 0xE8, 0xE0, 0xB1, 0x20,
|
||||
0x9B, 0xCB, 0x75, 0xAC, 0x4E, 0x54, 0xE9, 0x9D, 0x02, 0x21, 0x00, 0xE8, 0xF0,
|
||||
0xC0, 0x49, 0x23, 0x8E, 0x3D, 0x9B, 0xA5, 0x87, 0xA3, 0xBE, 0x6C, 0x21, 0x62,
|
||||
0xBB, 0xD2, 0x44, 0x5C, 0xE4, 0x7A, 0xCC, 0x46, 0x26, 0x04, 0x19, 0xA4, 0x2D,
|
||||
0x9B, 0x1C, 0x5D, 0x3A, 0x00, 0x75, 0x00, 0x6F, 0x53, 0x76, 0xAC, 0x31, 0xF0,
|
||||
0x31, 0x19, 0xD8, 0x99, 0x00, 0xA4, 0x51, 0x15, 0xFF, 0x77, 0x15, 0x1C, 0x11,
|
||||
0xD9, 0x02, 0xC1, 0x00, 0x29, 0x06, 0x8D, 0xB2, 0x08, 0x9A, 0x37, 0xD9, 0x13,
|
||||
0x00, 0x00, 0x01, 0x66, 0x9C, 0xC8, 0xE6, 0x20, 0x00, 0x00, 0x04, 0x03, 0x00,
|
||||
0x46, 0x30, 0x44, 0x02, 0x20, 0x14, 0xC8, 0x9F, 0xAC, 0x27, 0x48, 0xBE, 0x4D,
|
||||
0x0E, 0xC3, 0x26, 0x2E, 0x34, 0xCA, 0x38, 0xBA, 0x11, 0x3A, 0x68, 0x71, 0x88,
|
||||
0xEB, 0x24, 0x26, 0x59, 0x3E, 0xAC, 0xA8, 0x63, 0xCC, 0x8A, 0x0A, 0x02, 0x20,
|
||||
0x0F, 0x22, 0xBF, 0x0D, 0x1F, 0x8A, 0x8D, 0x1D, 0x91, 0x33, 0x3A, 0x40, 0xE4,
|
||||
0x23, 0x78, 0xFA, 0x22, 0xF5, 0x9B, 0xCB, 0x04, 0x4F, 0x53, 0x2D, 0x20, 0x75,
|
||||
0x2F, 0x76, 0x8A, 0xB1, 0xCD, 0x9D, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48,
|
||||
0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00,
|
||||
0x03, 0x41, 0x0F, 0xF3, 0xA6, 0x62, 0xA2, 0xE5, 0xB4, 0x8D, 0xA8, 0x08, 0x71,
|
||||
0x7B, 0xB3, 0xE3, 0x51, 0x61, 0x0D, 0xC0, 0x67, 0x6C, 0x3C, 0x9C, 0x00, 0x0B,
|
||||
0x63, 0x77, 0xB6, 0xB6, 0x11, 0x67, 0x77, 0xA5, 0xE1, 0x49, 0xE0, 0x7F, 0xB7,
|
||||
0x1D, 0x61, 0xFB, 0x83, 0x9C, 0x83, 0x42, 0xE9, 0x31, 0xCA, 0x51, 0xE3, 0xC1,
|
||||
0xBD, 0x9B, 0x2F, 0xB5, 0x35, 0x05, 0x72, 0x7F, 0x40, 0xA6, 0x7C, 0xC9, 0xF1,
|
||||
0x59, 0xA7, 0x15, 0xB8, 0x12, 0xDA, 0xF8, 0xCE, 0x83, 0x61, 0xFC, 0x47, 0x96,
|
||||
0x9E, 0x74, 0xFE, 0xCD, 0xE4, 0x61, 0x92, 0xF2, 0x2E, 0x0C, 0x08, 0x4B, 0x60,
|
||||
0x2D, 0xF6, 0x50, 0x07, 0x83, 0xCA, 0xAF, 0xB9, 0x41, 0x33, 0x4A, 0x3E, 0x84,
|
||||
0xC7, 0x73, 0xC6, 0x1F, 0xFF, 0x7A, 0xDF, 0xAE, 0x47, 0x25, 0x32, 0xEB, 0xC0,
|
||||
0x43, 0x0C, 0xA6, 0x23, 0x13, 0x46, 0xC3, 0xFA, 0x44, 0xEA, 0x20, 0xEA, 0xCB,
|
||||
0x18, 0x17, 0x00, 0xB6, 0xE7, 0x6D, 0x8A, 0x14, 0x8C, 0x6A, 0xCA, 0x88, 0x4C,
|
||||
0xDA, 0xA8, 0xB9, 0x08, 0xAF, 0x39, 0xEE, 0xCF, 0xD7, 0xF7, 0x32, 0xC0, 0xF4,
|
||||
0xCF, 0x4E, 0x22, 0x38, 0xF7, 0xAF, 0xAE, 0x7D, 0x58, 0x5F, 0xA5, 0x2D, 0x4D,
|
||||
0xBB, 0x86, 0x10, 0xB3, 0x93, 0x62, 0x64, 0x27, 0xBF, 0xB1, 0xBB, 0x8F, 0x9F,
|
||||
0xFC, 0x07, 0x3C, 0x4B, 0x16, 0x7A, 0x84, 0x5E, 0xAF, 0xAD, 0x57, 0x9C, 0xFF,
|
||||
0x7A, 0xA7, 0xE0, 0x90, 0x89, 0x1C, 0xE8, 0xE5, 0x11, 0xF7, 0xB6, 0xDC, 0xCD,
|
||||
0x5E, 0xF7, 0x30, 0xA2, 0x2E, 0x67, 0x6D, 0x4A, 0x70, 0x26, 0xEA, 0xCD, 0x27,
|
||||
0x70, 0x77, 0x54, 0x57, 0x09, 0x03, 0x56, 0x4A, 0x33, 0x60, 0x00, 0x27, 0xFE,
|
||||
0xA7, 0xD7, 0xA9, 0xC4, 0xEC, 0x17, 0x17, 0x8D, 0x87, 0x70, 0x6B, 0x48, 0x88,
|
||||
0x61, 0x54, 0x4A, 0x2B, 0xB7, 0x6A, 0x12, 0x08, 0xFB,
|
||||
};
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
CURLcode result;
|
||||
const char *beg = (const char *)&cert[0];
|
||||
const char *end = (const char *)&cert[sizeof(cert)];
|
||||
struct Curl_easy *data;
|
||||
int i;
|
||||
int byte;
|
||||
|
||||
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||
fprintf(stderr, "curl_global_init() failed\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
data = curl_easy_init();
|
||||
if(data) {
|
||||
result = Curl_extract_certinfo(data, 0, beg, end);
|
||||
|
||||
fail_unless(result == CURLE_OK, "Curl_extract_certinfo returned error");
|
||||
|
||||
/* a poor man's fuzzing of some initial data to make sure nothing bad
|
||||
happens */
|
||||
for(byte = 1 ; byte < 255; byte += 17) {
|
||||
for(i = 0; i < 45; i++) {
|
||||
char backup = cert[i];
|
||||
cert[i] = (unsigned char) (byte & 0xff);
|
||||
(void) Curl_extract_certinfo(data, 0, beg, end);
|
||||
cert[i] = backup;
|
||||
}
|
||||
}
|
||||
|
||||
curl_easy_cleanup(data);
|
||||
}
|
||||
curl_global_cleanup();
|
||||
}
|
||||
UNITTEST_STOP
|
||||
|
||||
#else
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
puts("not tested since Curl_extract_certinfo() is not built-in");
|
||||
}
|
||||
UNITTEST_STOP
|
||||
|
||||
#endif
|
||||
141
Engine/lib/curl/tests/unit/unit1652.c
Normal file
141
Engine/lib/curl/tests/unit/unit1652.c
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "urldata.h"
|
||||
#include "sendf.h"
|
||||
|
||||
/*
|
||||
* This test hardcodes the knowledge of the buffer size which is internal to
|
||||
* Curl_infof(). If that buffer is changed in size, this tests needs to be
|
||||
* updated to still be valid.
|
||||
*/
|
||||
|
||||
static struct Curl_easy *data;
|
||||
|
||||
static char input[4096];
|
||||
static char result[4096];
|
||||
|
||||
int debugf_cb(CURL *handle, curl_infotype type, char *buf, size_t size,
|
||||
void *userptr);
|
||||
|
||||
/*
|
||||
* This debugf callback is simply dumping the string into the static buffer
|
||||
* for the unit test to inspect. Since we know that we're only dealing with
|
||||
* text we can afford the luxury of skipping the type check here.
|
||||
*/
|
||||
int
|
||||
debugf_cb(CURL *handle, curl_infotype type, char *buf, size_t size,
|
||||
void *userptr)
|
||||
{
|
||||
(void)handle;
|
||||
(void)type;
|
||||
(void)userptr;
|
||||
|
||||
memset(result, '\0', sizeof(result));
|
||||
memcpy(result, buf, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static CURLcode
|
||||
unit_setup(void)
|
||||
{
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
data = curl_easy_init();
|
||||
if(!data) {
|
||||
curl_global_cleanup();
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
curl_easy_setopt(data, CURLOPT_DEBUGFUNCTION, debugf_cb);
|
||||
curl_easy_setopt(data, CURLOPT_VERBOSE, 1L);
|
||||
return res;
|
||||
}
|
||||
|
||||
static void
|
||||
unit_stop(void)
|
||||
{
|
||||
curl_easy_cleanup(data);
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
static int verify(const char *info, const char *two)
|
||||
{
|
||||
/* the 'info' one has a newline appended */
|
||||
char *nl = strchr(info, '\n');
|
||||
if(!nl)
|
||||
return 1; /* nope */
|
||||
return strncmp(info, two, nl - info);
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
/* Injecting a simple short string via a format */
|
||||
msnprintf(input, sizeof(input), "Simple Test");
|
||||
Curl_infof(data, "%s", input);
|
||||
fail_unless(verify(result, input) == 0, "Simple string test");
|
||||
|
||||
/* Injecting a few different variables with a format */
|
||||
Curl_infof(data, "%s %u testing %lu", input, 42, 43L);
|
||||
fail_unless(verify(result, "Simple Test 42 testing 43\n") == 0,
|
||||
"Format string");
|
||||
|
||||
/* Variations of empty strings */
|
||||
Curl_infof(data, "");
|
||||
fail_unless(strlen(result) == 1, "Empty string");
|
||||
Curl_infof(data, "%s", NULL);
|
||||
fail_unless(verify(result, "(nil)") == 0, "Passing NULL as string");
|
||||
|
||||
/* A string just long enough to not be truncated */
|
||||
memset(input, '\0', sizeof(input));
|
||||
memset(input, 'A', 2047);
|
||||
Curl_infof(data, "%s", input);
|
||||
fail_unless(strlen(result) == 2048, "No truncation of infof input");
|
||||
fail_unless(verify(result, input) == 0, "No truncation of infof input");
|
||||
fail_unless(result[sizeof(result) - 1] == '\0',
|
||||
"No truncation of infof input");
|
||||
|
||||
/* Just over the limit for truncation without newline */
|
||||
memset(input + 2047, 'A', 4);
|
||||
Curl_infof(data, "%s", input);
|
||||
fail_unless(strlen(result) == 2048, "Truncation of infof input 1");
|
||||
fail_unless(result[sizeof(result) - 1] == '\0', "Truncation of infof input 1");
|
||||
|
||||
/* Just over the limit for truncation with newline */
|
||||
memset(input + 2047, 'A', 4);
|
||||
memset(input + 2047 + 4, '\n', 1);
|
||||
Curl_infof(data, "%s", input);
|
||||
fail_unless(strlen(result) == 2048, "Truncation of infof input 2");
|
||||
fail_unless(result[sizeof(result) - 1] == '\0', "Truncation of infof input 2");
|
||||
|
||||
/* Way over the limit for truncation with newline */
|
||||
memset(input, '\0', sizeof(input));
|
||||
memset(input, 'A', sizeof(input) - 1);
|
||||
Curl_infof(data, "%s", input);
|
||||
fail_unless(strlen(result) == 2048, "Truncation of infof input 3");
|
||||
fail_unless(result[sizeof(result) - 1] == '\0', "Truncation of infof input 3");
|
||||
|
||||
|
||||
UNITTEST_STOP
|
||||
210
Engine/lib/curl/tests/unit/unit1653.c
Normal file
210
Engine/lib/curl/tests/unit/unit1653.c
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "urldata.h"
|
||||
#include "curl/urlapi.h"
|
||||
#include "urlapi-int.h"
|
||||
|
||||
|
||||
static CURLU *u;
|
||||
|
||||
static CURLcode
|
||||
unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
unit_stop(void)
|
||||
{
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
#define free_and_clear(x) free(x); x = NULL
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
CURLUcode ret;
|
||||
char *ipv6port = NULL;
|
||||
char *portnum;
|
||||
|
||||
/* Valid IPv6 */
|
||||
u = curl_url();
|
||||
if(!u)
|
||||
goto fail;
|
||||
ipv6port = strdup("[fe80::250:56ff:fea7:da15]");
|
||||
if(!ipv6port)
|
||||
goto fail;
|
||||
ret = Curl_parse_port(u, ipv6port, FALSE);
|
||||
fail_unless(ret == CURLUE_OK, "Curl_parse_port returned error");
|
||||
ret = curl_url_get(u, CURLUPART_PORT, &portnum, CURLU_NO_DEFAULT_PORT);
|
||||
fail_unless(ret != CURLUE_OK, "curl_url_get portnum returned something");
|
||||
free_and_clear(ipv6port);
|
||||
curl_url_cleanup(u);
|
||||
|
||||
/* Invalid IPv6 */
|
||||
u = curl_url();
|
||||
if(!u)
|
||||
goto fail;
|
||||
ipv6port = strdup("[fe80::250:56ff:fea7:da15|");
|
||||
if(!ipv6port)
|
||||
goto fail;
|
||||
ret = Curl_parse_port(u, ipv6port, FALSE);
|
||||
fail_unless(ret != CURLUE_OK, "Curl_parse_port true on error");
|
||||
free_and_clear(ipv6port);
|
||||
curl_url_cleanup(u);
|
||||
|
||||
u = curl_url();
|
||||
if(!u)
|
||||
goto fail;
|
||||
ipv6port = strdup("[fe80::250:56ff;fea7:da15]:80");
|
||||
if(!ipv6port)
|
||||
goto fail;
|
||||
ret = Curl_parse_port(u, ipv6port, FALSE);
|
||||
fail_unless(ret != CURLUE_OK, "Curl_parse_port true on error");
|
||||
free_and_clear(ipv6port);
|
||||
curl_url_cleanup(u);
|
||||
|
||||
/* Valid IPv6 with zone index and port number */
|
||||
u = curl_url();
|
||||
if(!u)
|
||||
goto fail;
|
||||
ipv6port = strdup("[fe80::250:56ff:fea7:da15%25eth3]:80");
|
||||
if(!ipv6port)
|
||||
goto fail;
|
||||
ret = Curl_parse_port(u, ipv6port, FALSE);
|
||||
fail_unless(ret == CURLUE_OK, "Curl_parse_port returned error");
|
||||
ret = curl_url_get(u, CURLUPART_PORT, &portnum, 0);
|
||||
fail_unless(ret == CURLUE_OK, "curl_url_get portnum returned error");
|
||||
fail_unless(portnum && !strcmp(portnum, "80"), "Check portnumber");
|
||||
curl_free(portnum);
|
||||
free_and_clear(ipv6port);
|
||||
curl_url_cleanup(u);
|
||||
|
||||
/* Valid IPv6 with zone index without port number */
|
||||
u = curl_url();
|
||||
if(!u)
|
||||
goto fail;
|
||||
ipv6port = strdup("[fe80::250:56ff:fea7:da15%25eth3]");
|
||||
if(!ipv6port)
|
||||
goto fail;
|
||||
ret = Curl_parse_port(u, ipv6port, FALSE);
|
||||
fail_unless(ret == CURLUE_OK, "Curl_parse_port returned error");
|
||||
free_and_clear(ipv6port);
|
||||
curl_url_cleanup(u);
|
||||
|
||||
/* Valid IPv6 with port number */
|
||||
u = curl_url();
|
||||
if(!u)
|
||||
goto fail;
|
||||
ipv6port = strdup("[fe80::250:56ff:fea7:da15]:81");
|
||||
if(!ipv6port)
|
||||
goto fail;
|
||||
ret = Curl_parse_port(u, ipv6port, FALSE);
|
||||
fail_unless(ret == CURLUE_OK, "Curl_parse_port returned error");
|
||||
ret = curl_url_get(u, CURLUPART_PORT, &portnum, 0);
|
||||
fail_unless(ret == CURLUE_OK, "curl_url_get portnum returned error");
|
||||
fail_unless(portnum && !strcmp(portnum, "81"), "Check portnumber");
|
||||
curl_free(portnum);
|
||||
free_and_clear(ipv6port);
|
||||
curl_url_cleanup(u);
|
||||
|
||||
/* Valid IPv6 with syntax error in the port number */
|
||||
u = curl_url();
|
||||
if(!u)
|
||||
goto fail;
|
||||
ipv6port = strdup("[fe80::250:56ff:fea7:da15];81");
|
||||
if(!ipv6port)
|
||||
goto fail;
|
||||
ret = Curl_parse_port(u, ipv6port, FALSE);
|
||||
fail_unless(ret != CURLUE_OK, "Curl_parse_port true on error");
|
||||
free_and_clear(ipv6port);
|
||||
curl_url_cleanup(u);
|
||||
|
||||
u = curl_url();
|
||||
if(!u)
|
||||
goto fail;
|
||||
ipv6port = strdup("[fe80::250:56ff:fea7:da15]80");
|
||||
if(!ipv6port)
|
||||
goto fail;
|
||||
ret = Curl_parse_port(u, ipv6port, FALSE);
|
||||
fail_unless(ret != CURLUE_OK, "Curl_parse_port true on error");
|
||||
free_and_clear(ipv6port);
|
||||
curl_url_cleanup(u);
|
||||
|
||||
/* Valid IPv6 with no port after the colon, should use default if a scheme
|
||||
was used in the URL */
|
||||
u = curl_url();
|
||||
if(!u)
|
||||
goto fail;
|
||||
ipv6port = strdup("[fe80::250:56ff:fea7:da15]:");
|
||||
if(!ipv6port)
|
||||
goto fail;
|
||||
ret = Curl_parse_port(u, ipv6port, TRUE);
|
||||
fail_unless(ret == CURLUE_OK, "Curl_parse_port returned error");
|
||||
free_and_clear(ipv6port);
|
||||
curl_url_cleanup(u);
|
||||
|
||||
/* Incorrect zone index syntax */
|
||||
u = curl_url();
|
||||
if(!u)
|
||||
goto fail;
|
||||
ipv6port = strdup("[fe80::250:56ff:fea7:da15!25eth3]:80");
|
||||
if(!ipv6port)
|
||||
goto fail;
|
||||
ret = Curl_parse_port(u, ipv6port, FALSE);
|
||||
fail_unless(ret != CURLUE_OK, "Curl_parse_port returned non-error");
|
||||
free_and_clear(ipv6port);
|
||||
curl_url_cleanup(u);
|
||||
|
||||
/* Non percent-encoded zone index */
|
||||
u = curl_url();
|
||||
if(!u)
|
||||
goto fail;
|
||||
ipv6port = strdup("[fe80::250:56ff:fea7:da15%eth3]:80");
|
||||
if(!ipv6port)
|
||||
goto fail;
|
||||
ret = Curl_parse_port(u, ipv6port, FALSE);
|
||||
fail_unless(ret == CURLUE_OK, "Curl_parse_port returned error");
|
||||
free_and_clear(ipv6port);
|
||||
curl_url_cleanup(u);
|
||||
|
||||
/* No scheme and no digits following the colon - not accepted. Because that
|
||||
makes (a*50):// that looks like a scheme be an acceptable input. */
|
||||
u = curl_url();
|
||||
if(!u)
|
||||
goto fail;
|
||||
ipv6port = strdup("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaa:");
|
||||
if(!ipv6port)
|
||||
goto fail;
|
||||
ret = Curl_parse_port(u, ipv6port, FALSE);
|
||||
fail_unless(ret == CURLUE_BAD_PORT_NUMBER, "Curl_parse_port did wrong");
|
||||
fail:
|
||||
free(ipv6port);
|
||||
curl_url_cleanup(u);
|
||||
|
||||
}
|
||||
UNITTEST_STOP
|
||||
142
Engine/lib/curl/tests/unit/unit1654.c
Normal file
142
Engine/lib/curl/tests/unit/unit1654.c
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2019 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "urldata.h"
|
||||
#include "altsvc.h"
|
||||
|
||||
static CURLcode
|
||||
unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
unit_stop(void)
|
||||
{
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
#if defined(CURL_DISABLE_HTTP) || defined(CURL_DISABLE_ALTSVC)
|
||||
UNITTEST_START
|
||||
{
|
||||
return 0; /* nothing to do when HTTP or alt-svc is disabled */
|
||||
}
|
||||
UNITTEST_STOP
|
||||
#else
|
||||
UNITTEST_START
|
||||
{
|
||||
char outname[256];
|
||||
CURL *curl;
|
||||
CURLcode result;
|
||||
struct altsvcinfo *asi = Curl_altsvc_init();
|
||||
if(!asi)
|
||||
return 1;
|
||||
result = Curl_altsvc_load(asi, arg);
|
||||
if(result) {
|
||||
Curl_altsvc_cleanup(&asi);
|
||||
return result;
|
||||
}
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
curl = curl_easy_init();
|
||||
if(!curl)
|
||||
goto fail;
|
||||
fail_unless(asi->list.size == 4, "wrong number of entries");
|
||||
msnprintf(outname, sizeof(outname), "%s-out", arg);
|
||||
|
||||
result = Curl_altsvc_parse(curl, asi, "h2=\"example.com:8080\"\r\n",
|
||||
ALPN_h1, "example.org", 8080);
|
||||
if(result) {
|
||||
fprintf(stderr, "Curl_altsvc_parse() failed!\n");
|
||||
unitfail++;
|
||||
}
|
||||
fail_unless(asi->list.size == 5, "wrong number of entries");
|
||||
|
||||
result = Curl_altsvc_parse(curl, asi, "h3=\":8080\"\r\n",
|
||||
ALPN_h1, "2.example.org", 8080);
|
||||
if(result) {
|
||||
fprintf(stderr, "Curl_altsvc_parse(2) failed!\n");
|
||||
unitfail++;
|
||||
}
|
||||
fail_unless(asi->list.size == 6, "wrong number of entries");
|
||||
|
||||
result = Curl_altsvc_parse(curl, asi,
|
||||
"h2=\"example.com:8080\", h3=\"yesyes.com\"\r\n",
|
||||
ALPN_h1, "3.example.org", 8080);
|
||||
if(result) {
|
||||
fprintf(stderr, "Curl_altsvc_parse(3) failed!\n");
|
||||
unitfail++;
|
||||
}
|
||||
/* that one should make two entries */
|
||||
fail_unless(asi->list.size == 8, "wrong number of entries");
|
||||
|
||||
result = Curl_altsvc_parse(curl, asi,
|
||||
"h2=\"example.com:443\"; ma = 120;\r\n",
|
||||
ALPN_h2, "example.org", 80);
|
||||
if(result) {
|
||||
fprintf(stderr, "Curl_altsvc_parse(4) failed!\n");
|
||||
unitfail++;
|
||||
}
|
||||
fail_unless(asi->list.size == 9, "wrong number of entries");
|
||||
|
||||
/* quoted 'ma' value */
|
||||
result = Curl_altsvc_parse(curl, asi,
|
||||
"h2=\"example.net:443\"; ma=\"180\";\r\n",
|
||||
ALPN_h2, "example.net", 80);
|
||||
if(result) {
|
||||
fprintf(stderr, "Curl_altsvc_parse(4) failed!\n");
|
||||
unitfail++;
|
||||
}
|
||||
fail_unless(asi->list.size == 10, "wrong number of entries");
|
||||
|
||||
result =
|
||||
Curl_altsvc_parse(curl, asi,
|
||||
"h2=\":443\", h3=\":443\"; ma = 120; persist = 1\r\n",
|
||||
ALPN_h1, "curl.se", 80);
|
||||
if(result) {
|
||||
fprintf(stderr, "Curl_altsvc_parse(5) failed!\n");
|
||||
unitfail++;
|
||||
}
|
||||
fail_unless(asi->list.size == 12, "wrong number of entries");
|
||||
|
||||
/* clear that one again and decrease the counter */
|
||||
result = Curl_altsvc_parse(curl, asi, "clear;\r\n",
|
||||
ALPN_h1, "curl.se", 80);
|
||||
if(result) {
|
||||
fprintf(stderr, "Curl_altsvc_parse(6) failed!\n");
|
||||
unitfail++;
|
||||
}
|
||||
fail_unless(asi->list.size == 10, "wrong number of entries");
|
||||
|
||||
Curl_altsvc_save(curl, asi, outname);
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
fail:
|
||||
Curl_altsvc_cleanup(&asi);
|
||||
curl_global_cleanup();
|
||||
return unitfail;
|
||||
}
|
||||
UNITTEST_STOP
|
||||
#endif
|
||||
192
Engine/lib/curl/tests/unit/unit1655.c
Normal file
192
Engine/lib/curl/tests/unit/unit1655.c
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2019 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "doh.h" /* from the lib dir */
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
/* whatever you want done first */
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
/* done before shutting down and exiting */
|
||||
}
|
||||
|
||||
#ifndef CURL_DISABLE_DOH
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
/*
|
||||
* Prove detection of write overflow using a short buffer and a name
|
||||
* of maximal valid length.
|
||||
*
|
||||
* Prove detection of other invalid input.
|
||||
*/
|
||||
do {
|
||||
const char *max =
|
||||
/* ..|....1.........2.........3.........4.........5.........6... */
|
||||
/* 3456789012345678901234567890123456789012345678901234567890123 */
|
||||
"this.is.a.maximum-length.hostname." /* 34: 34 */
|
||||
"with-no-label-of-greater-length-than-the-sixty-three-characters."
|
||||
/* 64: 98 */
|
||||
"specified.in.the.RFCs." /* 22: 120 */
|
||||
"and.with.a.QNAME.encoding.whose.length.is.exactly." /* 50: 170 */
|
||||
"the.maximum.length.allowed." /* 27: 197 */
|
||||
"that.is.two-hundred.and.fifty-six." /* 34: 231 */
|
||||
"including.the.last.null." /* 24: 255 */
|
||||
"";
|
||||
const char *toolong =
|
||||
/* ..|....1.........2.........3.........4.........5.........6... */
|
||||
/* 3456789012345678901234567890123456789012345678901234567890123 */
|
||||
"here.is.a.hostname.which.is.just.barely.too.long." /* 49: 49 */
|
||||
"to.be.encoded.as.a.QNAME.of.the.maximum.allowed.length."
|
||||
/* 55: 104 */
|
||||
"which.is.256.including.a.final.zero-length.label." /* 49: 153 */
|
||||
"representing.the.root.node.so.that.a.name.with." /* 47: 200 */
|
||||
"a.trailing.dot.may.have.up.to." /* 30: 230 */
|
||||
"255.characters.never.more." /* 26: 256 */
|
||||
"";
|
||||
const char *emptylabel =
|
||||
"this.is.an.otherwise-valid.hostname."
|
||||
".with.an.empty.label.";
|
||||
const char *outsizelabel =
|
||||
"this.is.an.otherwise-valid.hostname."
|
||||
"with-a-label-of-greater-length-than-the-sixty-three-characters-"
|
||||
"specified.in.the.RFCs.";
|
||||
int i;
|
||||
|
||||
struct test {
|
||||
const char *name;
|
||||
const DOHcode expected_result;
|
||||
};
|
||||
|
||||
/* plays the role of struct dnsprobe in urldata.h */
|
||||
struct demo {
|
||||
unsigned char dohbuffer[255 + 16]; /* deliberately short buffer */
|
||||
unsigned char canary1;
|
||||
unsigned char canary2;
|
||||
unsigned char canary3;
|
||||
};
|
||||
|
||||
const struct test playlist[4] = {
|
||||
{ toolong, DOH_DNS_NAME_TOO_LONG }, /* expect early failure */
|
||||
{ emptylabel, DOH_DNS_BAD_LABEL }, /* also */
|
||||
{ outsizelabel, DOH_DNS_BAD_LABEL }, /* also */
|
||||
{ max, DOH_OK } /* expect buffer overwrite */
|
||||
};
|
||||
|
||||
for(i = 0; i < (int)(sizeof(playlist)/sizeof(*playlist)); i++) {
|
||||
const char *name = playlist[i].name;
|
||||
size_t olen = 100000;
|
||||
struct demo victim;
|
||||
DOHcode d;
|
||||
|
||||
victim.canary1 = 87; /* magic numbers, arbritrarily picked */
|
||||
victim.canary2 = 35;
|
||||
victim.canary3 = 41;
|
||||
d = doh_encode(name, DNS_TYPE_A, victim.dohbuffer,
|
||||
sizeof(struct demo), /* allow room for overflow */
|
||||
&olen);
|
||||
|
||||
fail_unless(d == playlist[i].expected_result,
|
||||
"result returned was not as expected");
|
||||
if(d == playlist[i].expected_result) {
|
||||
if(name == max) {
|
||||
fail_if(victim.canary1 == 87,
|
||||
"demo one-byte buffer overwrite did not happen");
|
||||
}
|
||||
else {
|
||||
fail_unless(victim.canary1 == 87,
|
||||
"one-byte buffer overwrite has happened");
|
||||
}
|
||||
fail_unless(victim.canary2 == 35,
|
||||
"two-byte buffer overwrite has happened");
|
||||
fail_unless(victim.canary3 == 41,
|
||||
"three-byte buffer overwrite has happened");
|
||||
}
|
||||
else {
|
||||
if(d == DOH_OK) {
|
||||
fail_unless(olen <= sizeof(victim.dohbuffer), "wrote outside bounds");
|
||||
fail_unless(olen > strlen(name), "unrealistic low size");
|
||||
}
|
||||
}
|
||||
}
|
||||
} while(0);
|
||||
|
||||
/* run normal cases and try to trigger buffer length related errors */
|
||||
do {
|
||||
DNStype dnstype = DNS_TYPE_A;
|
||||
unsigned char buffer[128];
|
||||
const size_t buflen = sizeof(buffer);
|
||||
const size_t magic1 = 9765;
|
||||
size_t olen1 = magic1;
|
||||
const char *sunshine1 = "a.com";
|
||||
const char *dotshine1 = "a.com.";
|
||||
const char *sunshine2 = "aa.com";
|
||||
size_t olen2;
|
||||
DOHcode ret2;
|
||||
size_t olen;
|
||||
|
||||
DOHcode ret = doh_encode(sunshine1, dnstype, buffer, buflen, &olen1);
|
||||
fail_unless(ret == DOH_OK, "sunshine case 1 should pass fine");
|
||||
fail_if(olen1 == magic1, "olen has not been assigned properly");
|
||||
fail_unless(olen1 > strlen(sunshine1), "bad out length");
|
||||
|
||||
/* with a trailing dot, the response should have the same length */
|
||||
olen2 = magic1;
|
||||
ret2 = doh_encode(dotshine1, dnstype, buffer, buflen, &olen2);
|
||||
fail_unless(ret2 == DOH_OK, "dotshine case should pass fine");
|
||||
fail_if(olen2 == magic1, "olen has not been assigned properly");
|
||||
fail_unless(olen1 == olen2, "olen should not grow for a trailing dot");
|
||||
|
||||
/* add one letter, the response should be one longer */
|
||||
olen2 = magic1;
|
||||
ret2 = doh_encode(sunshine2, dnstype, buffer, buflen, &olen2);
|
||||
fail_unless(ret2 == DOH_OK, "sunshine case 2 should pass fine");
|
||||
fail_if(olen2 == magic1, "olen has not been assigned properly");
|
||||
fail_unless(olen1 + 1 == olen2, "olen should grow with the hostname");
|
||||
|
||||
/* pass a short buffer, should fail */
|
||||
ret = doh_encode(sunshine1, dnstype, buffer, olen1 - 1, &olen);
|
||||
fail_if(ret == DOH_OK, "short buffer should have been noticed");
|
||||
|
||||
/* pass a minimum buffer, should succeed */
|
||||
ret = doh_encode(sunshine1, dnstype, buffer, olen1, &olen);
|
||||
fail_unless(ret == DOH_OK, "minimal length buffer should be long enough");
|
||||
fail_unless(olen == olen1, "bad buffer length");
|
||||
} while(0);
|
||||
UNITTEST_STOP
|
||||
|
||||
#else /* CURL_DISABLE_DOH */
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
return 1; /* nothing to do, just fail */
|
||||
}
|
||||
UNITTEST_STOP
|
||||
|
||||
#endif
|
||||
179
Engine/lib/curl/tests/unit/unit1660.c
Normal file
179
Engine/lib/curl/tests/unit/unit1660.c
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2020 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "urldata.h"
|
||||
#include "hsts.h"
|
||||
|
||||
static CURLcode
|
||||
unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
unit_stop(void)
|
||||
{
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
#if defined(CURL_DISABLE_HTTP) || defined(CURL_DISABLE_HSTS)
|
||||
UNITTEST_START
|
||||
{
|
||||
return 0; /* nothing to do when HTTP or HSTS are disabled */
|
||||
}
|
||||
UNITTEST_STOP
|
||||
#else
|
||||
|
||||
struct testit {
|
||||
const char *host;
|
||||
const char *chost; /* if non-NULL, use to lookup with */
|
||||
const char *hdr; /* if NULL, just do the lookup */
|
||||
const CURLcode result; /* parse result */
|
||||
};
|
||||
|
||||
static const struct testit headers[] = {
|
||||
/* two entries read from disk cache, verify first */
|
||||
{ "-", "readfrom.example", NULL, CURLE_OK},
|
||||
{ "-", "old.example", NULL, CURLE_OK},
|
||||
/* delete the remaining one read from disk */
|
||||
{ "readfrom.example", NULL, "max-age=\"0\"", CURLE_OK},
|
||||
|
||||
{ "example.com", NULL, "max-age=\"31536000\"\r\n", CURLE_OK },
|
||||
{ "example.com", NULL, "max-age=\"21536000\"\r\n", CURLE_OK },
|
||||
{ "example.com", NULL, "max-age=\"21536000\"; \r\n", CURLE_OK },
|
||||
{ "example.com", NULL, "max-age=\"21536000\"; includeSubDomains\r\n",
|
||||
CURLE_OK },
|
||||
{ "example.org", NULL, "max-age=\"31536000\"\r\n", CURLE_OK },
|
||||
{ "this.example", NULL, "max=\"31536\";", CURLE_BAD_FUNCTION_ARGUMENT },
|
||||
{ "this.example", NULL, "max-age=\"31536", CURLE_BAD_FUNCTION_ARGUMENT },
|
||||
{ "this.example", NULL, "max-age=31536\"", CURLE_OK },
|
||||
/* max-age=0 removes the entry */
|
||||
{ "this.example", NULL, "max-age=0", CURLE_OK },
|
||||
{ "another.example", NULL, "includeSubDomains; ",
|
||||
CURLE_BAD_FUNCTION_ARGUMENT },
|
||||
|
||||
/* Two max-age is illegal */
|
||||
{ "example.com", NULL,
|
||||
"max-age=\"21536000\"; includeSubDomains; max-age=\"3\";",
|
||||
CURLE_BAD_FUNCTION_ARGUMENT },
|
||||
/* Two includeSubDomains is illegal */
|
||||
{ "2.example.com", NULL,
|
||||
"max-age=\"21536000\"; includeSubDomains; includeSubDomains;",
|
||||
CURLE_BAD_FUNCTION_ARGUMENT },
|
||||
/* use a unknown directive "include" that should be ignored */
|
||||
{ "3.example.com", NULL, "max-age=\"21536000\"; include; includeSubDomains;",
|
||||
CURLE_OK },
|
||||
/* remove the "3.example.com" one, should still match the example.com */
|
||||
{ "3.example.com", NULL, "max-age=\"0\"; includeSubDomains;",
|
||||
CURLE_OK },
|
||||
{ "-", "foo.example.com", NULL, CURLE_OK},
|
||||
{ "-", "foo.xample.com", NULL, CURLE_OK},
|
||||
|
||||
/* should not match */
|
||||
{ "example.net", "forexample.net", "max-age=\"31536000\"\r\n", CURLE_OK },
|
||||
|
||||
/* should not match either, since forexample.net is not in the example.net
|
||||
domain */
|
||||
{ "example.net", "forexample.net",
|
||||
"max-age=\"31536000\"; includeSubDomains\r\n", CURLE_OK },
|
||||
/* remove example.net again */
|
||||
{ "example.net", NULL, "max-age=\"0\"; includeSubDomains\r\n", CURLE_OK },
|
||||
|
||||
/* make this live for 7 seconds */
|
||||
{ "expire.example", NULL, "max-age=\"7\"\r\n", CURLE_OK },
|
||||
{ NULL, NULL, NULL, CURLE_OK }
|
||||
};
|
||||
|
||||
static void showsts(struct stsentry *e, const char *chost)
|
||||
{
|
||||
if(!e)
|
||||
printf("'%s' is not HSTS\n", chost);
|
||||
else {
|
||||
printf("%s [%s]: %" CURL_FORMAT_CURL_OFF_T "%s\n",
|
||||
chost, e->host, e->expires,
|
||||
e->includeSubDomains ? " includeSubDomains" : "");
|
||||
}
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
CURLcode result;
|
||||
struct stsentry *e;
|
||||
struct hsts *h = Curl_hsts_init();
|
||||
int i;
|
||||
const char *chost;
|
||||
CURL *easy;
|
||||
if(!h)
|
||||
return 1;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
easy = curl_easy_init();
|
||||
if(!easy) {
|
||||
Curl_hsts_cleanup(&h);
|
||||
curl_global_cleanup();
|
||||
return 1;
|
||||
}
|
||||
|
||||
Curl_hsts_loadfile(easy, h, "log/input1660");
|
||||
|
||||
for(i = 0; headers[i].host ; i++) {
|
||||
if(headers[i].hdr) {
|
||||
result = Curl_hsts_parse(h, headers[i].host, headers[i].hdr);
|
||||
|
||||
if(result != headers[i].result) {
|
||||
fprintf(stderr, "Curl_hsts_parse(%s) failed: %d\n",
|
||||
headers[i].hdr, result);
|
||||
unitfail++;
|
||||
continue;
|
||||
}
|
||||
else if(result) {
|
||||
printf("Input %u: error %d\n", i, (int) result);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
chost = headers[i].chost ? headers[i].chost : headers[i].host;
|
||||
e = Curl_hsts(h, chost, TRUE);
|
||||
showsts(e, chost);
|
||||
}
|
||||
|
||||
printf("Number of entries: %zu\n", h->list.size);
|
||||
|
||||
/* verify that it is exists for 7 seconds */
|
||||
chost = "expire.example";
|
||||
for(i = 100; i < 110; i++) {
|
||||
e = Curl_hsts(h, chost, TRUE);
|
||||
showsts(e, chost);
|
||||
deltatime++; /* another second passed */
|
||||
}
|
||||
|
||||
(void)Curl_hsts_save(easy, h, "log/hsts1660");
|
||||
Curl_hsts_cleanup(&h);
|
||||
curl_easy_cleanup(easy);
|
||||
curl_global_cleanup();
|
||||
return unitfail;
|
||||
}
|
||||
UNITTEST_STOP
|
||||
#endif
|
||||
115
Engine/lib/curl/tests/unit/unit1661.c
Normal file
115
Engine/lib/curl/tests/unit/unit1661.c
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, 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.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.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "bufref.h"
|
||||
|
||||
static struct bufref bufref;
|
||||
|
||||
static int freecount = 0;
|
||||
|
||||
static void test_free(void *p)
|
||||
{
|
||||
fail_unless(p, "pointer to free may not be NULL");
|
||||
freecount++;
|
||||
free(p);
|
||||
}
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
Curl_bufref_init(&bufref);
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
char *buffer = NULL;
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
/**
|
||||
* testing Curl_bufref_init.
|
||||
* @assumptions:
|
||||
* 1: data size will be 0
|
||||
* 2: reference will be NULL
|
||||
* 3: destructor will be NULL
|
||||
*/
|
||||
|
||||
fail_unless(!bufref.ptr, "Initial reference must be NULL");
|
||||
fail_unless(!bufref.len, "Initial length must be NULL");
|
||||
fail_unless(!bufref.dtor, "Destructor must be NULL");
|
||||
|
||||
/**
|
||||
* testing Curl_bufref_set
|
||||
*/
|
||||
|
||||
buffer = malloc(13);
|
||||
abort_unless(buffer, "Out of memory");
|
||||
Curl_bufref_set(&bufref, buffer, 13, test_free);
|
||||
|
||||
fail_unless((char *) bufref.ptr == buffer, "Referenced data badly set");
|
||||
fail_unless(bufref.len == 13, "Data size badly set");
|
||||
fail_unless(bufref.dtor == test_free, "Destructor badly set");
|
||||
|
||||
/**
|
||||
* testing Curl_bufref_ptr
|
||||
*/
|
||||
|
||||
fail_unless((char *) Curl_bufref_ptr(&bufref) == buffer,
|
||||
"Wrong pointer value returned");
|
||||
|
||||
/**
|
||||
* testing Curl_bufref_len
|
||||
*/
|
||||
|
||||
fail_unless(Curl_bufref_len(&bufref) == 13, "Wrong data size returned");
|
||||
|
||||
/**
|
||||
* testing Curl_bufref_memdup
|
||||
*/
|
||||
|
||||
result = Curl_bufref_memdup(&bufref, "1661", 3);
|
||||
abort_unless(result == CURLE_OK, curl_easy_strerror(result));
|
||||
fail_unless(freecount == 1, "Destructor not called");
|
||||
fail_unless((char *) bufref.ptr != buffer, "Returned pointer not set");
|
||||
buffer = (char *) Curl_bufref_ptr(&bufref);
|
||||
fail_unless(buffer, "Allocated pointer is NULL");
|
||||
fail_unless(bufref.len == 3, "Wrong data size stored");
|
||||
fail_unless(!buffer[3], "Duplicated data should have been truncated");
|
||||
fail_unless(!strcmp(buffer, "166"), "Bad duplicated data");
|
||||
|
||||
/**
|
||||
* testing Curl_bufref_free
|
||||
*/
|
||||
|
||||
Curl_bufref_free(&bufref);
|
||||
fail_unless(freecount == 1, "Wrong destructor called");
|
||||
fail_unless(!bufref.ptr, "Initial reference must be NULL");
|
||||
fail_unless(!bufref.len, "Initial length must be NULL");
|
||||
fail_unless(!bufref.dtor, "Destructor must be NULL");
|
||||
}
|
||||
UNITTEST_STOP
|
||||
Loading…
Add table
Add a link
Reference in a new issue