Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 19 Feb 2019 17:31:45 -0500
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: Error in getaddrinfo()?

On Tue, Feb 19, 2019 at 09:27:00PM +0100, Markus Wichmann wrote:
> Hi all,
> 
> I was just reading the getaddrinfo() source code, and I noticed
> something funny. On line 107 we have the wonderful text:
> 
> 		out[k].slot = i;
> 
> In context, k counts through all the outputs, i counts all the addresses
> and j counts the ports. I was wondering about this line and looked for
> where slot might be used. Its only use is in freeaddrinfo(), where it is
> used to find the head of the output array. But then the slot should be
> set to k, right?
> 
> I mean, it works wonderfully in the normal use case, where you call
> freeaddrinfo() with the first element of the list. It also works in all
> cases if nservs == 1, which is the case if the IPPROTO is set explicitly
> in the hints structure. But otherwise?
> 
> According to POSIX, freeaddrinfo() has to support freeing "arbitrary
> sublists" of the list originally returned by getaddrinfo(). I presume
> that means "tail", because there is no way to free only a certain middle
> part of the list.

I think you're right, and this should be k, not i. From your reading,
will that fix the problem?

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.