88.26. tinyxml-2.6.2
Small C++ XML parser (TinyXML 1)
| Version | 2.6.2, release 2 |
| Shelf | formats — Data-format and serialisation libraries (XML, JSON, YAML, TOML, INI, RDF, protobuf, thrift), plus data query and convert tools |
| Phase | 41_system (System), 556 of 1047 in build order |
| Licence | Zlib |
| Homepage | https://sourceforge.net/projects/tinyxml/ |
| Build time | 0.1 SBU |
| Installed size | 232.4 KiB in 7 files |
| Recipe | ports/core/formats/tinyxml/kpkgbuild |
About
TinyXML is a small C++ XML parser that reads a document into a tree of objects and writes one back out. This is TinyXML 1, the original library, not its successor tinyxml2, which has a different API. KDOS carries it for the two programs that link it, kodi and opencpn.
Upstream ships no way to build the library: its Makefile builds only the xmltest program, with the four library sources compiled into it. build.sh therefore compiles the four sources itself, links them into libtinyxml.so.0, installs the two headers and writes a tinyxml.pc for pkg-config; the release has neither a library target nor a .pc file.
Sources
tinyxml-2.6.2.tar.gz(205.2 KiB)
sha25615bdfdcec58a7da30adc87ac2b078e4417dbe5392f3afb719f9ba6d062645593
upstream: https://downloads.sourceforge.net/tinyxml/tinyxml_2_6_2.tar.gz
archive copy: sources-2/formats--tinyxml-2.6.2.tar.gz
Dependencies
Depends on: nothing a recipe names.
Required by (2): kodi, opencpn.
Patches
build.sh applies these; kpkg applies nothing by itself.
CVE-2021-42260.patch— InTiXmlParsingData::Stamp, advances one byte past a0xEFlead byte when either of the two bytes after it is the terminating NUL. Without it the pointer does not move in that case, so a document ending in a truncated three-byte UTF-8 sequence makes the parser loop forever (CVE-2021-42260). The patch is Debian’s and carries aDescription:header rather than aSubject:.CVE-2023-34194.patch— Avoid reachable assertion via crafted XML document with a '\0' located after whitespaceBug: https://www.forescout.com/resources/sierra21-vulnerabilities Bug-Debian: https://bugs.debian.org/1059315 Bug-Debian: https://security-tracker.debian.org/tracker/CVE-2023-34194 Bug-Debian: https://security-tracker.debian.org/tracker/CVE-2023-40462
define-stl.patch— Adds#define TIXML_USE_STL 1at the top oftinyxml.h, so every program that includes the header sees the STL build of the classes that the library was compiled as, without having to pass-DTIXML_USE_STLitself.entity.patch— Removes the special case inTiXmlBase::EncodeStringthat copied a hexadecimal character reference (&#x…;) through unchanged. Every&is then written as&, so text that only looks like a character reference survives a parse and a save intact. It also adds an “Entity escaping” case for this toxmltest.cpp.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install tinyxml'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/formats/tinyxml.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/formats/tinyxml
echo '15bdfdcec58a7da30adc87ac2b078e4417dbe5392f3afb719f9ba6d062645593 tinyxml-2.6.2.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/tinyxml
SRC=$SRC_ROOT/tinyxml-2.6.2
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf tinyxml-2.6.2.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers _ver and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
for p in define-stl entity CVE-2021-42260 CVE-2023-34194; do
patch -p1 -i "$PORT_SRC/$p.patch"
done
for f in tinyxml tinystr tinyxmlerror tinyxmlparser; do
$CXX $CXXFLAGS -fPIC -DTIXML_USE_STL -c "$f.cpp" -o "$f.o"
done
$CXX $CXXFLAGS $LDFLAGS -shared -Wl,-soname,libtinyxml.so.0 \
-o libtinyxml.so.0.$version \
tinyxml.o tinystr.o tinyxmlerror.o tinyxmlparser.o
install -Dm755 libtinyxml.so.0.$version "$PKG/usr/lib/libtinyxml.so.0.$version"
ln -s libtinyxml.so.0.$version "$PKG/usr/lib/libtinyxml.so.0"
ln -s libtinyxml.so.0.$version "$PKG/usr/lib/libtinyxml.so"
install -Dm644 tinyxml.h "$PKG/usr/include/tinyxml.h"
install -Dm644 tinystr.h "$PKG/usr/include/tinystr.h"
install -d "$PKG/usr/share/licenses/$name"
head -n 23 tinyxml.h > "$PKG/usr/share/licenses/$name/LICENSE"
install -d "$PKG/usr/lib/pkgconfig"
cat > "$PKG/usr/lib/pkgconfig/tinyxml.pc" <<EOF
prefix=/usr
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include
Name: TinyXML
Description: Small C++ XML parser
Version: $version
Libs: -L\${libdir} -ltinyxml
Cflags: -I\${includedir}
EOF
The switches, and why each is set:
-DTIXML_USE_STL— Build the library with STL support:TIXML_STRINGbecomesstd::stringinstead of TinyXML’s ownTiXmlString, and thestd::stringand stream overloads of the API are compiled in. The same macro is set in the installed header bydefine-stl.patch, because the choice changes the layout of the classes (theirvalue,nameand other members areTIXML_STRING), so a program and the library must agree on it.-Wl,-soname,libtinyxml.so.0— Give the library the shared-object namelibtinyxml.so.0, which a program linked against it records as its dependency. The file itself islibtinyxml.so.0.<version>, withlibtinyxml.so.0andlibtinyxml.soas symbolic links to it.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/tinyxml, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf tinyxml-2.6.2-2.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/tinyxml, and runs the triggers its paths call for.
Contents
Installed libraries: libtinyxml.so.
Installed directories: /usr/share/licenses/tinyxml.
Short descriptions
tinyxml.pc |
Small C++ XML parser |