Re: tcptrace-bugs Static variable returns of HostName() are not consider by callers

From: Shawn Ostermann (
Date: 01/04/06

Message-Id: <>
From: Shawn Ostermann <>
Subject: Re: tcptrace-bugs Static variable returns of HostName() are not consider by callers
Date: Wed, 4 Jan 2006 14:44:07 -0500

We should talk about this first. The extra overhead of the strdup()
plus the free() after the printf() will be expensive. And, of
course, somebody will forget to use free, or will have a custom bit
of code that doesn't use it, which will lead to a terrible memory
leak that will be very difficult to find.

I guess my suggestion is to:

1) Change the name of HostName() to something like TempHostName() and
then use that everywhere instead in OUR code
2) Create a new HostName() that calls TempHostName() and then strdup().

I can't remember for sure, how soon do you lose the HostName()
buffer? Is it nondeterministic?


On Jan 4, 2006, at 12:57 PM, Manikantan Ramadas wrote:

>>> Every where else where HostName() gets called, it is merely
>>> for debug-help printf messages;
>> I agree, the hazard is there but it is ignored only in few debug
>> printf()
>> (AFAIK). It really *did* manifest as wrong behavior that made
>> debugging of
>> another bug in 6.6.1 (when dst_port==src_port, seems to be fixed
>> now in
>> 6.6.7) a lot harder until I fixed the printf()s... It's not nice
>> though
>> suggesting that debugging printf()s are allowed to mislead, which was
>> the case in this instance...
> I was under the impression that no one ran into a manifestation
> of this wrong behavior (by which I mean incorrect debug printfs),
> and therefore took the stance of why fix things if they aren't broken.
> But I take your word on this one. The easiset fix would be to wrap
> up those HostName() calls in strdup() in those debug printfs.
> Should be easy to do. I shall do that for the long over-due next
> bugfix release of tcptrace.
> Thanks,
> Mani.
> --
> "The quieter you become, the more you can hear." - Baba Ram Dass.
> ____________________________________________________________________
> * Manikantan Ramadas * IRG, OU * *
> ____________________________________________________________________

This archive was generated by hypermail 2.1.7 : 01/05/06 EST