Re: in_ntoa interesting fault

Ricky Beam (root@defiant.mintel.net)
Tue, 11 Jun 1996 23:10:13 -0400 (EDT)


Letting the chips far where they may, I quote Alan Cox:
>
>> Well, today I built 2.0.0 (fresh, minus all the evil things I've done over the
>> past year) to get three different numbers. And then I changed them to in_ntoa
>> and what did I get but the first number three times!
>>
>> Do I smell a gcc fart?!
>
>No. Read the source code carefully this time. in_ntoa uses a static buffer
>

I realize that now... insufficient caffeine level!

The really interesting thing is seeing how the compiler builds:
printk("fluff %s %s %s\n", in_ntoa(1), in_ntoa(2), in_ntoa(3));

That will print:
fluff 1.0.0.0 1.0.0.0 1.0.0.0 (well, maybe I have byte ordering wrong)

The calls to in_ntoa occur "backwards" and all return the same address thanks
to the "static char buffer[16]." This routine smells of a hideous #define
macro (I've done that before) or exploit gcc and create some vars in the
middle of a function. (Or compile the kernel with g++ <grin>)

--Ricky

Gee, look at the trouble I go through to avoid hex IP addresses!