From: Loganaden Velvindron <logan@elandsys.com>
To: Jan Engelhardt <jengelh@inai.de>
Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>,
Loganaden Velvindron <loganaden@gmail.com>,
netfilter-devel@vger.kernel.org
Subject: Re: Harden iptables memory allocator
Date: Fri, 22 May 2015 04:51:48 -0700 [thread overview]
Message-ID: <20150522115148.GA1985@mx.elandsys.com> (raw)
In-Reply-To: <alpine.LSU.2.20.1505221056510.29609@nerf40.vanv.qr>
On Fri, May 22, 2015 at 10:59:44AM +0200, Jan Engelhardt wrote:
>
> On Friday 2015-05-22 10:50, Hannes Frederic Sowa wrote:
> >
> >> + if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
> >
> >if ((nmemb|size) >= MUL_NO_OVERFLOW) && ...
>
> I am sure there are many C tricks one can do, but iptables is
> hardly that time-critical to warrant such.
The same can be said of ipset, which uses strlcpy and has strlcat in
its library. However, those are safer APIs to use.
In this particular case, it's safer to use reallocarray(NULL,x,y) rather than
malloc(x*y).
(Many other less critical software such as m4 have also adopted reallocarray).
> The compiler should perhaps learn to do such an optimization
> if it does not already.
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-05-22 11:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-21 18:42 Harden iptables memory allocator Loganaden Velvindron
2015-05-21 19:29 ` Loganaden Velvindron
2015-05-22 8:50 ` Hannes Frederic Sowa
2015-05-22 8:59 ` Jan Engelhardt
2015-05-22 11:51 ` Loganaden Velvindron [this message]
2015-05-22 12:06 ` Jan Engelhardt
2015-05-22 10:49 ` Loganaden Velvindron
2015-05-25 17:56 ` Pablo Neira Ayuso
2015-05-25 18:59 ` Loganaden Velvindron
2015-05-25 19:28 ` Pablo Neira Ayuso
2015-05-25 19:52 ` Loganaden Velvindron
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=20150522115148.GA1985@mx.elandsys.com \
--to=logan@elandsys.com \
--cc=hannes@stressinduktion.org \
--cc=jengelh@inai.de \
--cc=loganaden@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).