Package: xml2
Version: 0.4-3.1
Severity: normal
Tags: upstream
To reproduce:
$ echo -e '/fooa/foo/a=mesh\n/fooa/foo/b=desh'|2csv foo a b
(no output)
$ echo -e '/fooa/foo/a=mesh\n/fooa/foo/b=desh'|2csv fooa/foo a b
mesh,desh
The output should be the same in both situations. (Except that the
documentation lacks 2csv examples, so it's hard to tell how exactly 2csv
should be used.)
The bug is here in 2csv.c:
find = strstr(buffer,record);
if (NULL == find || '/' != find[record_len]
|| (buffer != find && '/' != find[-1])) {
dump(argc,fields,quote,delimiter);
continue;
}
it tries to check whether we got out of a record and should dump the
record values, but because strstr only finds the _first_ occurrence of
the record identifier, the logic does not work if there are
superelements of the record element which contain its name as a
substring of their name.
-- System Information:
Debian Release: 8.2
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=fi_FI.UTF-8, LC_CTYPE=fi_FI.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages xml2 depends on:
ii libc6 2.19-18+deb8u1
ii libxml2 2.9.1+dfsg1-5+deb8u1
xml2 recommends no packages.
xml2 suggests no packages.
-- no debconf information