[270] in Hesiod
Re: to free or not to free
daemon@ATHENA.MIT.EDU (Todd C. Miller)
Tue May 23 13:05:05 1995
To: hesiod@MIT.EDU
In-Reply-To: Your message of "Mon, 22 May 1995 19:07:48 MDT."
<199505230107.TAA16400@clytemnestra.cs.colorado.edu>
Date: Tue, 23 May 1995 10:58:54 -0600
From: "Todd C. Miller" <Todd.Miller@cs.colorado.edu>
In message <199505230107.TAA16400@clytemnestra.cs.colorado.edu>
so spake "Todd C. Miller" (Todd.Miller):
> In looking at other code that uses hesiod it seems that people
> are freeing the buffer returned by hes_resolve(). Now, in the
> source on athena-dist the buffer is static and should not be free(3)'d.
> Are there other hesiod implementations that do use a dynamically
> allocated buffer? If so, is there any real way of telling which
> implementation you are dealing with?
Well, I finally realized why people are free(3)'ing the buffer
hes_resolve() returns (myself included). The programmer's guide
explicately tells you to do so. Not only is this completely false
it is dangerous since the guide then goes on to state that
successive calls to hes_resolve() won't clobber the previous data.
Wrong! A look at res_scan() reveals that it is a static buffer
that *does* get overwritten on successive calls. I have verified
that the ultrix hes_resolv() does the same thing. Below are diffs
that correct doc/programmer.txt.
- todd