[rrd-developers] [PATCH] rrd_restore.c: Use libxml2 to parse the input.

Florian Forster rrdtool at nospam.verplant.org
Tue Mar 11 14:20:48 CET 2008


Hi,

almost a year ago I fixed a segfault in `rrd_restore.c' and proposed to
use one of the XML parsing libraries to prevent such problems in the
future. Unfortunately I didn't have much time to look into that until
this week.

I've rewritten `rrd_restore.c' from scratch and used libxml2 to parse
the input. The code is not very strict, so *any* text in blocks is
ignored[1], the order or tags may differ (depending on the tag, [2]),
parameters of RRAs are not checked against the type of the RRA, etc.
It's *possible* to create broken RRDs if you try hard enough.

The code *should* provide the same features as the old code. However,
I've only tested the code with my relatively simple files, i. e. with
RRAs of type `AVERAGE', `MIN', `MAX' and `LAST'. I did NOT YET test the
other RRA types, i. e. the Holt-Winters stuff. I also did NOT YET test
the `COMPUTE' data source type. Thus, please consider this code to be
work in progress. Any feedback is very welcome, of course.

Attached are two files:
- `rrd_restore-libxml2.patch' is a patch against the 1.2.27 distribution
  which also adds a check for libxml2 to the configure script.
- `rrd_restore.c' is the plain new file because that patch is a bit hard
  to read.

Regards,
-octo

[1] This means, for example, that the following input will not cause an
    error and `foobar' will silently be ignored:
    -- 8< --
    <rrd>
      <version> 0003 </version>
      foobar
      <step> 10 </step>
      ...
    </rrd>
    -- >8 --
[2] The order of <version> and <step> within <rrd> doesn't matter, for
    instance. <ds> blocks must still appear before <rra> blocks and <ds>
    blocks within <cdp_prep> blocks must be in the same order as the DS
    definition and so on.
    If a DS is defined after an RRA the resulting RRD file will most
    likely be broken.
-- 
Florian octo Forster
Hacker in training
GnuPG: 0x91523C3D
http://verplant.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rrd_restore-libxml2.patch
Type: text/x-diff
Size: 51079 bytes
Desc: not available
Url : http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20080311/e2eb928e/attachment-0003.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rrd_restore.c
Type: text/x-csrc
Size: 26942 bytes
Desc: not available
Url : http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20080311/e2eb928e/attachment-0004.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20080311/e2eb928e/attachment-0005.bin 


More information about the rrd-developers mailing list