From: Patrick McHardy <kaber@trash.net>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Sen Haerens <sen@rotsen.be>,
Netfilter Development Mailinglist
<netfilter-devel@vger.kernel.org>
Subject: Re: [conntrack-tools] XML output is invalid
Date: Fri, 20 Jun 2008 16:05:15 +0200 [thread overview]
Message-ID: <485BB91B.7010303@trash.net> (raw)
In-Reply-To: <485BB63A.6000404@netfilter.org>
Pablo Neira Ayuso wrote:
> Patrick McHardy wrote:
>> Pablo Neira Ayuso wrote:
>>> Does this patch help?
>>>
>>>
>>> + if (output_mask & _O_XML) {
>>> op_type = NFCT_O_XML;
>>> + if (dump_xml_header_done) {
>>> + dump_xml_header_done = 0;
>>> + len = snprintf(buf, 1024, "<?xml version=\"1.0\"?>\n"
>>> + "<conntrack>\n");
>>> + }
>>> + }
>>> if (output_mask & _O_EXT)
>>> op_flags = NFCT_OF_SHOW_LAYER3;
>>> if (output_mask & _O_ID)
>>> op_flags |= NFCT_OF_ID;
>>>
>>> - nfct_snprintf(buf, 1024, ct, NFCT_T_UNKNOWN, op_type, op_flags);
>>> + nfct_snprintf(buf+len, 1024-len, ct, NFCT_T_UNKNOWN, op_type,
>>> op_flags);
>>
>> It doesn't seem to matter here, but that looks buggy (combined
>> with the snprintf above). When the buffer size is exceed, snprintf
>> returns the amount of characters it *would have written* if
>> enough space was available. So when this really happens above,
>> you have a buffer overflow in the second snprintf.
>
> The string above has a fixed size and the buffer is big enough to print
> the flow entry, so the buffer overflow is very unlikely.
Yeah, its more a correctness thing. And it might lead to
problems later on.
> Anyhow, I think that the following patch perform more strict and robust
> checkings regarding the buffer size. I hope that you like better :).
Probably, but its missing from this mail :)
next prev parent reply other threads:[~2008-06-20 14:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <F7825499-A8F5-4F41-B3DD-2E13807954E2@rotsen.be>
2008-06-20 13:24 ` [conntrack-tools] XML output is invalid Pablo Neira Ayuso
2008-06-20 13:30 ` Patrick McHardy
2008-06-20 13:52 ` Pablo Neira Ayuso
2008-06-20 14:05 ` Patrick McHardy [this message]
2008-06-20 14:06 ` Pablo Neira Ayuso
2008-06-20 14:03 ` Jan Engelhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=485BB91B.7010303@trash.net \
--to=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=sen@rotsen.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.