Re: [PATCH iptables] libxtables: Fix xtables_ipaddr_to_numeric calls with xtables_ipmask_to_numeric

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Mar 24, 2024 at 12:37:53AM +0300, Vitaly Chikunov wrote:
> On Sat, Mar 23, 2024 at 02:56:43PM +0100, Phil Sutter wrote:
> > On Sat, Mar 23, 2024 at 06:06:41AM +0300, Vitaly Chikunov wrote:
> > > Frequently when addr/mask is printed xtables_ipaddr_to_numeric and
> > > xtables_ipmask_to_numeric are called together in one printf call but
> > > xtables_ipmask_to_numeric internally calls xtables_ipaddr_to_numeric
> > > which prints into the same static buffer causing buffer to be
> > > overwritten and addr/mask incorrectly printed in such call scenarios.
> > > 
> > > Make xtables_ipaddr_to_numeric to use two static buffers rotating their
> > > use. This simplistic approach will leave ABI not changed and cover all
> > > such use cases.
> > 
> > I don't quite like the cat'n'mouse game this opens, although it's
> > unlikely someone calls it a third time before copying the buffer.
> > 
> > What do you think about the attached solution?
> 
> Your approach is indeed much better. But why double underscore prefix
> to a function name, this sounds like reserved identifiers.

Well, for once it was just a quick sketch. Also, when refactoring into
an inner function it is not uncommon to prefix it this way, at least if
it's an internal-only function.

Another option I could think of is _r suffix, typically used for
reentrant variants.

Cheers, Phil




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux