delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/12/10/14:25:47

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Tue, 10 Dec 2002 14:22:44 -0500
From: "Pierre A. Humblet" <pierre DOT humblet AT ieee DOT org>
To: cygwin AT cygwin DOT com
Subject: Re: cygwin 1.3.17-1 gethostbyname() leak
Message-ID: <20021210192244.GA250329@WORLDNET>
References: <Pine DOT GSO DOT 4 DOT 44 DOT 0212101024110 DOT 12239-100000 AT slinky DOT cs DOT nyu DOT edu> <009001c2a080$11adb510$3492fea9 AT NOELG>
Mime-Version: 1.0
In-Reply-To: <009001c2a080$11adb510$3492fea9@NOELG>
User-Agent: Mutt/1.4i

On Wed, Dec 11, 2002 at 06:12:21AM +1100, Noel Gordon wrote:

> If it is true that cygwin uses gethostbyname() from wsock32.dll, and
> returns the wsock32.dll hostent* result to the application, then it
> is perhaps unwise to free() it. Following your tip, we find from ...
> 

In net.cc cygwin takes the result from the MS GetHostByName and copies
it to its own calloc'ed structure.
Not sure why, given that the MS function already returns a pointer to
a per thread structure, as indicated below.

Pierre
 
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/gethostby
> name_2.asp
> 
>   Remarks
> 
>   The gethostbyname function returns a pointer to a hostent structure - a
>   structure allocated by Windows Sockets. The hostent structure contains
>   the results of a successful search for the host specified in the name
>   parameter [of gethostbyname()].
> 
>   The application must never attempt to modify this structure or to free
>   any of its components. Furthermore, only one copy of this structure is
>   allocated per thread, so the application should copy any information it
>   needs before issuing any other Windows Sockets function calls.
> 

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019