0
0
mirror of https://github.com/zeux/pugixml.git synced 2024-12-28 23:03:00 +08:00

1446 Commits

Author SHA1 Message Date
Arseny Kapoulkine
08f102f14c tests: Add even more stream coverage tests
Apparently only narrow character streams had out of memory coverage -
fix that and also split this into a separate test.
2017-06-16 21:38:55 -07:00
Arseny Kapoulkine
86593c0999 tests: Add more stream coverage tests
Cover both char and wchar_t stream loading in a single run instead of
using pugi::char_t.
2017-06-16 17:08:00 -07:00
Arseny Kapoulkine
3aa2b40354 tests: Add more coverage tests for stream loading
Cover more failure cases and simplify the streambuf implementation a
bit.
2017-06-16 16:41:08 -07:00
Arseny Kapoulkine
b6995f06b9 Fix BorlandC compilation
Rename partition to partition3 to resolve conflicts with std::partition.
2017-06-16 00:32:01 -07:00
Arseny Kapoulkine
bd23216420 tests: Improve XPath test coverage
Add more memory allocation failure tests.
2017-06-16 00:29:14 -07:00
Arseny Kapoulkine
a3664ea971 tests: Expand write_flush coverage
Adjust the buffer size to be right on the edge of the overflow, make
sure we actually output " instead of ".
2017-06-16 00:09:32 -07:00
Arseny Kapoulkine
d2892be902 tests: Add xml_buffered_writer coverage test
This test triggers flush() condition for each optimized write() method.
2017-06-15 23:52:56 -07:00
Arseny Kapoulkine
95f013ba80 Refactor snprintf support
Instead of branching code at each invocation site, use variadic macros
to create a wrapping macro that use snprintf for the buffer of a
statically known size.

Variadic macros are supported by all C++11 compilers, as is snprintf;
on MSVC 2005+ we don't necessarily have snprintf, but we can use
_snprintf_s with _TRUNCATE to get the same behavior. In all other cases
we fall back to sprintf, that (theoretically) can lead to a stack buffer
overflow.

In practice all snprintfs used in pugixml use buffers that should be
large enough to never be overflown but snprintf is safe even if this is
not the case.
2017-06-15 23:35:20 -07:00
Arseny Kapoulkine
207bc788e9 Use buffer with a static size in convert_number_to_mantissa_exponent
We use references to arrays elsewhere in the codebase and there's just
one caller for this function so it's easier to fix the size.

This will simplify snprintf refactoring.
2017-06-15 22:58:46 -07:00
Arseny Kapoulkine
cd2804d3ee Merge pull request #145 from noresources/snprintf
use snprintf instead of sprintf
2017-06-15 21:34:04 -07:00
Arseny Kapoulkine
0698810abb Merge pull request #149 from zeux/test-path
Improve code coverage
2017-06-15 21:17:26 -07:00
Arseny Kapoulkine
927d321d90 Exclude unreachable lines from code coverage
codecov.io does not seem to support lcov regex customization;
additionally, we can't just replace unreachable with LCOV_LINE_EXCL
in gcov file - so we have to patch the ##### indicator (which suggests
the line hasn't been hit) with 1.

See also https://github.com/codecov/support/issues/144
2017-06-15 20:58:26 -07:00
Arseny Kapoulkine
b3b44841f0 Mark all assert(false) statements as unreachable
Now we can exclude these from code coverage since it's logically
impossible to hit them in tests.
2017-06-15 09:26:23 -07:00
Arseny Kapoulkine
c40fd364ce tests: Add tests for loading special files
New tests try to load a folder as an XML document, and a device. Both
are intended to exercise some otherwise non-hittable error paths in
load_file implementation.
2017-06-15 07:23:49 -07:00
Ivan Gagis
b66ca4f326 use 2 images to build on appveyor 2017-06-15 11:49:10 +03:00
Ivan Gagis
4dc1054104 use powershell instead of cmd 2017-06-15 11:32:46 +03:00
Ivan Gagis
e944623780 Appveyor image set to VS2017 2017-06-15 11:17:34 +03:00
Ivan Gagis
042eae4c83 Appveyor image set to VS2017 2017-06-15 11:14:28 +03:00
Ivan Gagis
d8f9148d36 set v141 tools environment for building 2017-06-15 11:11:36 +03:00
Ivan Gagis
3a8073cca2 Appveyor image set to VS2017 2017-06-15 11:05:28 +03:00
Ivan Gagis
c7131b01f9 VS2017 project 2017-06-15 10:59:33 +03:00
Arseny Kapoulkine
0fbc043183 tests: Increase compact_pointer coverage
This adds tests that complete branch coverage in compact pointer
encoding/decoding code (previously first_attribute was always encoded
using compact encoding in the entire test suite).
2017-06-14 23:50:21 -07:00
Arseny Kapoulkine
52da6f71d0 Increase the minimum CMake version to 2.8.12
This is a followup to 198900eff403982f080958459f1ccb45cdefe9a4.

target_include_directories was introduced in 2.8.12, thus CMake 2.6 no
longer works.
2017-06-14 23:06:32 -07:00
Renaud Guillard
0d8022eced use snprintf if available, _snprintf or sprintf otherwise 2017-06-11 18:33:28 +02:00
Renaud Guillard
810f1f600d use _snprintf if MSVC 2017-06-05 13:31:58 +02:00
Renaud Guillard
b5e9d933ad use snprintf instead of sprintf 2017-06-04 21:10:19 +02:00
Arseny Kapoulkine
38edf255ae Work around -fsanitize=integer issues
Integer sanitizer is flagging unsigned integer overflow in several
functions in pugixml; unsigned integer overflow is well defined but it
may not necessarily be intended.

Apart from hash functions, both string_to_integer and integer_to_string
use unsigned overflow - string_to_integer uses it to perform
two-complement negation so that the bulk of the operation can run using
unsigned integers. This makes it possible to simplify overflow checking.
Similarly integer_to_string negates the number before generating a
decimal representation, but negating is impossible without unsigned
overflow or special-casing certain integer limits.

For now just silence the integer overflow using a special attribute;
also move unsigned overflow into string_to_integer from get_value_* so
that we have fewer functions marked with the attribute.

Fixes #133.
2017-04-03 23:35:24 -07:00
Arseny Kapoulkine
24d1a4562b Move libFuzzer build to Makefile
Now the only thing fuzz_setup.sh does is installing new clang; if system
clang supports -fsanitize-coverage then fuzz_setup.sh is not required.
2017-04-03 21:09:37 -07:00
Arseny Kapoulkine
0eb1ddb975 tests: Fix fuzz_setup.sh
The script only worked if clang folder was already created.
2017-04-03 20:36:33 -07:00
Arseny Kapoulkine
101f32884f Add missing PUGI__FN to string_to_integer 2017-03-21 22:06:19 -07:00
Arseny Kapoulkine
956be4ca4b Revert "Fix gcc-4.8 compilation warning when using -Wstrict-overflow"
This reverts commit 79109a8546f963d17522d75112cffcfd8cbe35fc.

This warning does not happen on gcc-4.8.4; the workaround introduces an
unsigned integer overflow which results in a runtime error when compiled
with integer sanitizer.
2017-03-21 21:57:16 -07:00
Arseny Kapoulkine
acfe47ba52 tests: Do not use unsigned underflow in test code
This triggers a runtime error under integer sanitizer
2017-03-21 21:47:22 -07:00
Arseny Kapoulkine
c29940ca72 tests: Fix invalid buffer size
This was triggering an buffer read overflow with asan.
2017-03-21 10:33:20 -07:00
Arseny Kapoulkine
db98a7e28b Fix path to fuzzing corpus 2017-03-21 10:28:20 -07:00
Arseny Kapoulkine
640c94f90d Merge pull request #134 from ogdf/explicit-fallthroughs
Silence g++ 7.0.1 -Wimplicit-fallthrough warnings
2017-03-06 07:43:40 -08:00
Stephan Beyer
87fc170cdf Silence g++ 7.0.1 -Wimplicit-fallthrough warnings
This is accomplished by putting a // fallthrough
comment at the right place.
This seems to be more portable than an attribute-based
solution like [[fallthrough]] or __attribute__((fallthrough)).
2017-03-05 22:12:10 +01:00
Arseny Kapoulkine
8ce4592e15 Simplify compact_hash_table implementation
Instead of a separate implementation for find/insert, use just one that
can do both. This reduces the code size and simplifies code coverage;
the resulting code is close to what we had in terms of performance and
since hash table is a fall back should not affect any real workloads.
2017-03-03 07:11:22 -08:00
Arseny Kapoulkine
03e4b8de92 Merge pull request #132 from zeux/fuzz
Improve fuzzing support
2017-02-11 13:51:39 -08:00
Arseny Kapoulkine
ec984370fb tests: Fix fuzz_setup.sh
Make the file executable, fix Windows newlines and fix clang setup.
2017-02-11 13:17:27 -08:00
Arseny Kapoulkine
ea544eb48b tests: Add fuzzing dictionaries
Hopefully this will allow for better fuzzing coverage
2017-02-11 13:17:02 -08:00
Arseny Kapoulkine
8c62fa9121 tests: Add XPath fuzzing
Only fuzz the parser for now.
2017-02-09 07:37:38 -08:00
Arseny Kapoulkine
8b15ae8015 tests: Add a script to set up fuzzing tools
This downloads a clang build that has support for instrumentation, and also
downloads and compiles libFuzzer.a.
2017-02-09 07:37:04 -08:00
Arseny Kapoulkine
00ef791078 fuzz: Use libFuzzer instead of afl-fuzz
This allows us to have faster fuzz cycles since the fuzzer is in-process.
2017-02-09 07:36:32 -08:00
Arseny Kapoulkine
e748f435e5 tests: Increase the number of translate calls
This should make the test fail on a 32-bit target.
2017-02-09 07:36:32 -08:00
Arseny Kapoulkine
4bab082a27 tests: Fix clang build 2017-02-09 07:36:32 -08:00
Arseny Kapoulkine
ba39838ab5 tests: Add more XPath out of memory tests 2017-02-09 07:36:31 -08:00
Arseny Kapoulkine
d4c456bdef Add invalid type assertion for offset_debug
This will make sure we don't forget to implement offset_debug for new
node types if they ever happen (really it's mostly for consistency).
2017-02-09 07:36:31 -08:00
Arseny Kapoulkine
02c599f52b tests: Increase the number of translate calls
This should make the test fail on a 32-bit target.
2017-02-08 01:18:11 -08:00
Arseny Kapoulkine
b98c914053 tests: Fix clang build 2017-02-08 00:33:51 -08:00
Arseny Kapoulkine
1688f44185 tests: Add more XPath out of memory tests 2017-02-08 00:09:32 -08:00