1
0
mirror of https://github.com/leethomason/tinyxml2.git synced 2026-07-21 19:23:00 +04:00
Commit Graph

452 Commits

Author SHA1 Message Date
Lee Thomason 999a21fa86 Dead platform removal (#1068)
Remove dead platforms.
2026-05-23 16:41:46 -07:00
Lee Thomason a737ecb2cb Fixes from security review (#1067)
Security fix
2026-05-23 16:36:17 -07:00
Lee Thomason 8d8472fe1a Improved XMLNode::~XMLNode perfomance (#1075)
Improved XMLNode::~XMLNode perfomance (#1075)
2026-05-23 16:13:32 -07:00
Lee Thomason 418229dc5c fix bad merge 2026-03-09 18:02:29 -07:00
zhthhh aba13c50bf Fix issue #1048: Add null pointer check in XMLDocument::DeleteNode (#1057)
- Add null pointer check in XMLDocument::DeleteNode() method
- Add test case to verify null pointer handling
- Prevents segmentation fault when calling DeleteNode(nullptr)
2026-03-09 17:32:22 -07:00
sbaluja e48a1310fe Add null check for format in TIXML_VSCPRINTF (#1064) 2026-03-09 17:31:36 -07:00
LuridHound c4e29afeaf Fix issue 1000 (#1040)
* fix compilation warnings produced by -Wold-style-cast

* remove incorrect cast
2025-11-22 16:08:17 -08:00
Lee Thomason 5c9a452c73 Merge fallthrough to cpp (#1052)
Fix warnings on merge fallthroughs
2025-11-22 16:02:49 -08:00
Malcolm Tyrrell 487f42aa69 Optional apos escaping 2025-03-29 18:13:43 +00:00
Albert Hung 0ca3584fa4 Fix ARM Compiler build errors
Fix build errors on ARM Compiler 5 (DS-5) by treating the compiler like QNX, Borland C, and the Android NDK for purposes of system header includes.
2024-12-17 10:13:57 +08:00
Lee Thomason 1fadaae0c9 another defensive check 2024-12-09 21:39:30 -08:00
Lee Thomason ff48ea1bae improve fix 2024-12-09 21:17:33 -08:00
Lee Thomason 494735de30 fix the potential overflow in char refs 2024-12-04 18:07:15 -08:00
Albert Hung 162bd4e925 Fixed -Wold-style-cast warnings
Fixed old-style-cast warnings
2024-12-02 13:47:07 +08:00
Jan Engelhardt eb3ab0df5d Make DynArray support objects larger than 1 gigabyte
The expression ``const int newAllocated = cap * 2;`` easily causes
overflow, as soon as the input is 1.0 GiB. This goes unnoticed because
release builds of tinyxml2 do not have active assertions.

The change in commit 9.0.0-20-g8fd6cc6 did not do anything useful;
the signed multiplication overflow (and thus undefined behavior)
still occurs.

Using ``int`` in this class is really archaic, because it limits the
class to a gigabyte even on 64-bit platforms.

The multiplication overflow check also needs to include sizeof(T),
otherwise you can run into unsigned multiplication overflow (defined,
but undesirable) in the memcpy() call.

testcase:

int main()
{
        tinyxml2::XMLDocument doc;
        doc.InsertEndChild(doc.NewDeclaration());
        auto root = doc.NewElement("root");
        size_t sz = 0x80000001;
        auto blank = new char[sz];
        memset(blank, ' ', sz);
        blank[sz-1]='\0';
        root->SetText(blank);
        doc.InsertEndChild(root);
        tinyxml2::XMLPrinter printer(nullptr);
        doc.Print(&printer);
}
2024-07-01 22:07:51 +02:00
Jan Engelhardt 3a893e5757 Remove extraneous +x bit from source files 2024-07-01 14:14:33 +02:00
Albert Hung dded8bb2e9 Fix format specifier mismatch in XMLUtil::ToStr
In the XMLUtil::ToStr( uint64_t v, char* buffer, int bufferSize ) function, the format specifier %llu was used with a signed long long argument. This caused a type mismatch warning. The argument has been changed to unsigned long long to match the format specifier, resolving the warning.
2024-05-15 19:43:55 +08:00
Lee Thomason 312a809224 Merge pull request #976 from leethomason/AlbertHungGarmin-format_error
Albert hung garmin format error
2024-04-20 19:46:41 -07:00
Lee Thomason c33aae04d9 kick the system 2024-04-20 19:44:22 -07:00
David Oakley dfc20c5f8f Android SDK<24 doesn’t support fseeko/ftello
Fall back to using fseek/ftell;
This was broken by https://github.com/leethomason/tinyxml2/pull/903/commits/d9fb8d34439be452c18b63713e2e0ae0e6028072
2024-04-08 12:58:12 +01:00
Albert Hung 1d658f0d95 Fix format error of TIXML_SNPRINTF
The format "%x" is treated as an unsigned int by the GCC compiler. Use static_cast to cast the error to an unsigned int to match the "%x" type. Additionally, replace int(error) with static_cast<int>(error) to avoid the old-style cast warning.
2024-03-19 14:22:17 +08:00
Lee Thomason 6b6d1214a7 Merge branch 'work/dfaure/Wundef' of https://github.com/dfaure-kdab/tinyxml2 into dfaure-kdab-work/dfaure/Wundef 2023-11-21 12:35:56 -08:00
Lee Thomason 2d59aaf0da Merge branch 'master' of https://github.com/vimproved/tinyxml2 into vimproved-master 2023-11-21 12:16:06 -08:00
Lee Thomason 9d026527a4 Merge branch 'pedantic-whitespace' of https://github.com/kcsaul/tinyxml2 into kcsaul-pedantic-whitespace 2023-11-21 11:40:52 -08:00
David Faure 5080faafe6 Add missing "defined", to fix building with -Werror=undef 2023-09-17 21:39:55 +02:00
Violet Purcell f439598036 Remove LFS64 calls and set _FILE_OFFSET_BITS=64
Musl 1.2.4 made the LFS64 interfaces only available when
_LARGEFILE64_SOURCE is defined, and they will be removed altogether in
Musl 1.2.5. This commit replaces the LFS64 calls with their non-LFS64
versions and defines _FILE_OFFSET_BITS=64, which makes all interfaces
64-bit.

Bug: https://bugs.gentoo.org/905999
2023-06-09 01:43:27 +00:00
Kevin Saul 98303bbda3 add pedantic whitespace mode 2023-05-28 21:36:28 +12:00
kb1sph 5926ec938a Added ChildElementCount()
Added the ChildElementCount function that was initially suggested by msteiger on sourceforge for the original tinyxml.  Modified to work with TinyXML-2.
2023-02-06 19:04:57 -05:00
Lee Thomason 94f52b5cbe Merge branch 'dinghao188-dev' of https://github.com/dinghao188/tinyxml2 into dinghao188-dinghao188-dev 2023-01-14 17:41:42 -08:00
Lee Thomason 7e310468f3 typo 2022-04-02 14:15:59 -07:00
Lee Thomason 953018ab93 fix android build 2022-04-02 14:14:20 -07:00
Lee Thomason a2d675139b fix cygwin 2022-04-02 14:05:47 -07:00
Saran Tunyasuvunakool 4cc4145d7f Change argument names in tinyxml2.cpp to match those in tinyxml2.h.
Affected functions are `XMLElement::QueryUnsigned64Text` and `XMLDocument::Parse`.
2021-12-21 16:06:24 +00:00
Saran Tunyasuvunakool 6cc405853b Convert endings of lines 106-107 in tinyxml2.cpp to CRLF. 2021-12-21 16:05:29 +00:00
dinghao188 9efb6b0b66 fix assertion - Assertion '_elementPool.CurrentAllocs() == _elementPool.Untracked()' failed. 2021-09-17 17:49:01 +08:00
striker.sh 98233b604b Use fseeko and ftello on BSDs 2021-06-13 20:24:00 +02:00
Jonas Vautherin 41151ce211 Add defined(__ANDROID__) for fseeko defined and android-x86_64 2021-05-19 02:43:44 +02:00
Lee Thomason 91bfd4b7fc Merge pull request #827 from ngc92/ClearError
removed overhead of clear error
2020-12-30 10:35:45 -08:00
Lee Thomason a9ed6746dd Merge pull request #838 from dfaure-kdab/Wundef
Add missing `defined`, detected by -Werror=undef
2020-12-30 10:18:44 -08:00
Lee Thomason 11376382fa Merge pull request #840 from dota17/master
skip comment node before get text
2020-12-30 10:18:16 -08:00
Will Pazner d3a82c5e45 Fix format string errors in sscanf 2020-11-19 20:50:36 -08:00
dota17 d59fd15db6 skip comment node before get text 2020-10-22 15:16:34 +08:00
David Faure b5d3b93e05 Add missing defined, detected by -Werror=undef 2020-10-09 09:59:50 +02:00
ngc92 2c6a41a92e removed overhead of clear error 2020-07-30 23:51:30 +03:00
Lee Thomason 2e6912bf8a Merge pull request #816 from a-lunkov/master
Suppress UndefinedBehaviorSanitizer warnings
2020-06-13 17:52:03 -07:00
Lee Thomason 1578df3bf8 Merge pull request #811 from hyperair/fix-first-line-indentation
XMLPrinter: Fix first line indentation
2020-06-13 17:38:20 -07:00
Lee Thomason 18468b8cc4 minor changes to hex parsing 2020-06-13 17:35:21 -07:00
Lee Thomason c9c9d8cdfa Merge branch 'master' of https://github.com/netcan/tinyxml2 into netcan-master 2020-06-13 17:26:30 -07:00
a-lunkov a953b9565d Suppress UndefinedBehaviorSanitizer warnings
I compiled tinyxml2 with the following changes to CMakeLists.txt:
-------------------------------------------------- ------------------------------------------
set (CMAKE_C_COMPILER "/ usr / local / bin / clang10")
set (CMAKE_CXX_COMPILER "/ usr / local / bin / clang ++ 10")
add_compile_options (-g)
add_compile_options (-fsanitize = address, undefined, integer, alignment, bool, builtin, bounds, enum, function, nonnull-attribute, null, object-size, pointer-overflow, return, returns-nonnull-attribute, unreachable, vla-bound , vptr)

set_source_files_properties (tinyxml2.cpp tinyxml2.h
                            PROPERTIES COMPILE_FLAGS -fsanitize = address, undefined, integer, alignment, bool, builtin, bounds, enum, function, nonnull-attribute, null, object-size, pointer-overflow, return, returns-nonnull-attribute, unreachable, vla-bound , vptr)
TARGET_LINK_LIBRARIES (tinyxml2 /usr/local/llvm10/lib/clang/10.0.0/lib/freebsd/libclang_rt.asan-x86_64.a /usr/local/llvm10/lib/clang/10.0.0/lib/freebsd/libang asan_cxx-x86_64.a /usr/local/llvm10/lib/clang/10.0.0/lib/freebsd/libclang_rt.ubsan_standalone-x86_64.a /usr/local/llvm10/lib/clang/10.0.0/lib/freebsd/ libclang_rt.ubsan_standalone_cxx-x86_64.a -lpthread)
-------------------------------------------------- ------------------------------------------
(Sorry for the dirty code.)

And launched the xmltest utility:
-------------------------------------------------- ------------------------------------------
/home/qqq/17_tinyxml2/tinyxml2-master/tinyxml2.cpp:237:37: runtime error: implicit conversion from type 'char' of value -48 (8-bit, signed) to type 'unsigned char' changed the value to 208 (8-bit, unsigned)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/qqq/17_tinyxml2/tinyxml2-master/tinyxml2.cpp:237:37 in
/home/qqq/17_tinyxml2/tinyxml2-master/tinyxml2.cpp:243:40: runtime error: implicit conversion from type 'char' of value -96 (8-bit, signed) to type 'unsigned char' changed the value to 160 (8-bit, unsigned)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/qqq/17_tinyxml2/tinyxml2-master/tinyxml2.cpp:243:40 in
/home/qqq/17_tinyxml2/tinyxml2-master/tinyxml2.cpp:1912:39: runtime error: implicit conversion from type 'char' of value -48 (8-bit, signed) to type 'unsigned char' changed the value to 208 (8-bit, unsigned)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/qqq/17_tinyxml2/tinyxml2-master/tinyxml2.cpp:1912:39 in
-------------------------------------------------- ------------------------------------------
2020-05-13 18:24:08 +03:00
Lee Thomason bfbcc0333d Merge pull request #809 from a-lunkov/patch-1
Fix for build with FreeBSD
2020-03-31 15:09:26 -07:00