cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker mailing list Archives

[ curl-Bugs-1911069 ] Race Condition in Curl_resolv(hostip.c) (dns cache)

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Tue, 11 Mar 2008 04:58:25 -0700

Bugs item #1911069, was opened at 2008-03-10 16:31
Message generated for change (Comment added) made by imercury
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1911069&group_id=976

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: libcurl
Group: crash
Status: Open
Resolution: None
Priority: 7
Private: No
Submitted By: Andrey (imercury)
Assigned to: Daniel Stenberg (bagder)
Summary: Race Condition in Curl_resolv(hostip.c) (dns cache)

Initial Comment:
Hello.

I've noticed a bug in Curl_resolv which can lead to crash of curl(or bad behaviour)(I've checked versions 7.16.1 and 7.18.0, but I think older versions are also buggy). Look at hostip.c:423 (curl 7.18.0). Consider we're sharing dns cache between 2 threads(A and B).
A: locks dns cache
A: gets dns from cache
A: unlocks dns cache
B: locks dns cache
B: gets dns from cache
B: unlock dns cache
A: checks remove_entry_if_stale and it returns true
.
So dns entry is removed from cache and thread A knows it, so it sets dns = NULL; but thread B doesn't know it and it has dns variable pointed to nobody knows what...

My solution for that, diff hostip_old.c hostip.c (v7.18.0) is attached. Not sure it's ok, but it worked on 7.16.1 (at least I didn't get curl crashed).

Regards, Andrew..

----------------------------------------------------------------------

>Comment By: Andrey (imercury)
Date: 2008-03-11 14:58

Message:
Logged In: YES
user_id=2032292
Originator: YES

Not sure it's ok though. It just works in my case..
File Added: mydiff

----------------------------------------------------------------------

Comment By: Daniel Stenberg (bagder)
Date: 2008-03-11 01:33

Message:
Logged In: YES
user_id=1110
Originator: NO

Thanks a lot, but can you please make the diff with -u and submit such a
version?

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1911069&group_id=976
Received on 2008-03-11

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET