lkml.org 
[lkml]   [1996]   [Jun]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: in_ntoa interesting fault
Date
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!


\
 
 \ /
  Last update: 2005-03-22 13:37    [W:0.049 / U:3.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site