211 Commits

Author SHA1 Message Date
Nick Mathewson
9f39c88756 Fix a crash in evdns related to shutting down evdns
Patch from YASUOKA Masahiko; fix for libevent github issue #113.
2014-03-21 14:08:17 -04:00
Greg Hazel
363388a043 restore the comment 2013-05-29 14:19:14 -07:00
Azat Khuzhin
f8d7df8591 Fix SEGFAULT after evdns_base_resume if no nameservers installed.
If there is no nameservers installed, using
evdns_base_nameserver_ip_add(), than evdns_base_resume() will SEGFAULT,
because of NULL dereference in evdns_requests_pump_waiting_queue()

Conflicts:
	evdns.c
2013-05-29 14:05:17 -07:00
Belobrov Andrey
5c710c0362 Checking request nameserver for NULL, before using it. 2013-05-07 10:01:36 -04:00
George Danchev
f2bff75ed8 FIx another memleak on OOM in evdns 2012-09-12 20:12:03 -04:00
George Danchev
73e85dd08f Avoid a memory-leak on OOM in evdns. 2012-09-12 20:11:12 -04:00
Greg Hazel
dc3207767d Avoid segfault on weird timeout during name lookup.
If an evdns_getaddrinfo timeout happens while pending_cb is set, and
a callback is about to run, but we get a call to
evdns_getaddrinfo_gotresolve before it finishes.

Github issue #60. Thanks to Greg Hazel for patch and patience.
2012-07-30 17:01:52 -04:00
Nick Mathewson
a1a0e67531 memset sockaddr_in before using it. Found by coverity. 2012-07-26 10:38:29 -04:00
Nick Mathewson
265e6779dd Fix evdns build with threads disabled
The last evdns change apparently broke it, by using a "base"
variable that we were only declaring with threads turned on.
2012-05-02 16:52:27 -04:00
Nick Mathewson
3d9e52ac56 When retransmitting a timed-out DNS request, pick a fresh nameserver.
Otherwise, requests initially sent to a failing nameserver would
stay there indefinitely, even if other nameservers would work.

Fix for sourceforge bug 3518439
2012-05-01 19:52:55 -04:00
Nick Mathewson
d873d6787c Make some evdns.c debug logs more verbose 2012-05-01 19:52:49 -04:00
Greg Hazel
46b806084e remove redundant DNS_ERR_CANCEL check, move comment 2012-04-18 21:41:48 -07:00
Greg Hazel
94d2336070 cancel the probe request when the server is freed, and ignore cancelled probe callbacks 2012-04-18 21:29:21 -07:00
Nick Mathewson
bec50680a3 Stop crashing in evdns when nameserver probes give a weird error
When a nameserver is down, we periodically try sending a "probe"
message to that nameserver to see if it has come back up.  If a
nameserver comes up, we cancel any pending probe messages.

Cancelling a probe message while handling the probe's response would
result in a access-after-free or a double-free, so when we notice that
we're about to call a nameserver up because of having received a probe
from it, we need to check whether current response is the response
from the probe.

There was a case where we didn't to that, though: when the resolver
gave us an unusual error response to our request that it resolve
google.com.  This is pretty rare, but apparently it can happen with
some weird cacheing nameservers -- the one on the mikrotik router, for
example.  Without this patch, we would crash with a NULL pointer
derefernce.

Thanks to Hannes Sowa for finding this issue and helping me track it
down.
2012-02-15 20:25:31 -05:00
Nick Mathewson
e49e289129 Update copyright notices to 2012 2012-02-10 17:29:53 -05:00
Nick Mathewson
d6094b160f evdns: fix a bug in circular-queue implementation
found by Wang Qin
2012-02-01 14:56:43 -05:00
Leonid Evdokimov
21a08d6869 Empty DNS reply with OK status is another way to say NODATA.
Sometimes DNS reply has nothing but query section. It does not look like
error, so it should be treated as NODATA with TTL=0 as soon as there is
no SOA record to deduce negative TTL from.
2011-10-19 22:15:35 -04:00
Nick Mathewson
39c0cf7ca4 Fix some "value never used" warnings with gcc 4.6.1 2011-10-03 12:49:02 -04:00
Leonid Evdokimov
94fba5b9ac Add DNS_ERR_NODATA error code to handle empty replies. 2011-09-12 15:38:05 -04:00
Leonid Evdokimov
f72e8f6643 DNS: add ttl for negative answers using RFC 2308 idea. 2011-09-01 11:03:51 -04:00
Leonid Evdokimov
aff6ba15a1 Fix request_finished memory leak with debugging turned on. 2011-08-15 11:12:57 -04:00
Nick Mathewson
06a714ffe4 Fix new warnings from GCC 4.6 2011-05-25 16:52:03 -04:00
Nick Mathewson
74760f1864 Fix a bug that prevented us from configuring IPv6 nameservers. 2011-05-23 17:45:50 -04:00
Sebastian Hahn
5208544edc Fix possible NULL-deref in evdns_cancel_request
The clang static analyzer complained that base might be dereferenced
without being set, but this patch should fix another dereference issue.
2011-04-23 02:04:58 +02:00
Nick Mathewson
364291e9a9 Handle calloc failure in evdns. (Found by Dave Hart) 2011-04-21 17:11:41 -04:00
Nick Mathewson
00e91b3c8d Fix a crash bug in evdns server circular list code
Really, this should use a circleq.  That's a change for 2.1, though.
2011-04-20 13:27:31 -04:00
Nick Mathewson
3417f6808d Avoid a free(NULL) if out-of-memory in evdns_getaddrinfo. Found by Dave Hart 2011-04-13 11:20:30 -04:00
Jardel Weyrich
666b096691 Detect and handle more allocation failures. 2011-01-07 13:03:31 -05:00
Evan Jones
fbe64f216c Use relative includes instead of system includes consistently. 2010-12-02 11:03:55 -05:00
Nick Mathewson
7bcace2d54 Fix some irix compilation warnings spotted by Kevin Bowling 2010-11-22 21:02:34 -05:00
Nick Mathewson
d51b2fc655 Make evdns_getaddrinfo_cancel threadsafe 2010-11-19 12:14:18 -05:00
Nick Mathewson
c7cfbcf466 Fix some more cancel-related bugs in getaddrinfo_async
Also imposed a new rule to make this much much simpler: no freeing
the getaddrinfo request until both dns callbacks have been invoked.
2010-11-19 12:08:35 -05:00
Nick Mathewson
abf01ed13a Avoid double-invocation of user callback with EVUTIL_EAI_CANCEL 2010-11-19 12:08:34 -05:00
Nick Mathewson
494186129f Use the US-English "canceled", not the UK "cancelled". 2010-11-19 12:08:29 -05:00
Nick Mathewson
5c8a59e886 Merge remote branches 'github/20_evdns_cancel_segfault_v2', 'github/20_http_close_detect', 'github/20_http_versions', 'github/20_more_http_methods', 'github/20_shutdown_iocp_listener' and 'github/20_win64_fixes' 2010-11-09 10:19:05 -05:00
Nick Mathewson
9ed30de7ff Don't free evdns_request handles until after the callback is invoked
Previously, once the callback was scheduled, it was unsafe to cancel
a request, but there was no way to tell that.  Now it is safe to
cancel a request until the callback is invoked, at which point it
isn't.

Found and diagnosed by Denis Bilenko.
2010-11-04 11:05:29 -04:00
Nick Mathewson
ba01456999 Use the label_len local variable in evdns instead of recalculating it over and over 2010-11-02 12:42:35 -04:00
Nick Mathewson
545a61145c Fix even more win64 warnings: buffer, event_tagging, http, evdns, evrpc 2010-11-01 14:13:33 -04:00
Nick Mathewson
5b7a370636 Fix warnings on mingw with gcc 4.5 2010-10-05 14:29:48 -04:00
Nick Mathewson
a8b7674cd5 Merge remote branch 'github/signed_compare' 2010-09-28 01:09:17 -04:00
Nick Mathewson
d49b5e3326 Do not search outside of the system directory for windows DLLs
Hardens against some attacks.
2010-09-27 15:45:34 -04:00
Nick Mathewson
9c8db0f804 Fix all warnings in the main codebase flagged by -Wsigned-compare
Remember, the code
   int is_less_than(int a, unsigned b) {
      return a < b;
   }
is buggy, since the C integer promotion rules basically turn it into
   int is_less_than(int a, unsigned b) {
      return ((unsigned)a) < b;
   }
and we really want something closer to
   int is_less_than(int a, unsigned b) {
      return a < 0 || ((unsigned)a) < b;
   }
.

Suggested by an example from Ralph Castain
2010-09-23 22:45:55 -04:00
Nick Mathewson
749128b2cf Merge remote branch 'github/win32_posix_underscore' 2010-09-04 22:02:32 -04:00
Nick Mathewson
195214360c Expose a function to add a nameserver by sockaddr 2010-09-03 16:42:16 -04:00
Nick Mathewson
e50c0fcc85 Use the _func() replacements for open, fstat, etc in evutil.c on win32
Remember that in a fit of ANSI C compliance, Microsoft decided to
screw portability by renaming basically all the functions in unistd.h to
get prefixed with an understore.

For some reason, mingw didn't seem to mind, but at least some people's
compilers did: see bug 3044490.
2010-09-02 13:13:28 -04:00
Nick Mathewson
d0b884338f Set close-on-exec bit for filedescriptors created by dns subsystem.
Based on patch for 1.4 by Ralf Schmitt.
2010-08-18 10:49:12 -04:00
Nick Mathewson
ec347b9225 Move event-config.h to include/event2
This change means that all required include files are in event2, and
all files not in event2/* are optional.
2010-08-06 20:21:27 -04:00
Nick Mathewson
5fa30d2bf4 Fix evdns build with -DUNICODE
It turns out that GetProcAddress always takes its second argument as
a C string, regardless of whether unicode is on or not.
2010-08-06 17:13:27 -04:00
Nick Mathewson
cc2379d264 Constify a couple of arguments to evdns_server_request_add_*_reply 2010-07-26 14:48:32 -04:00
Nick Mathewson
e1c1167cbe Replace (unused,always 0) is_tcp argument to evdns_add_server_port*() with flags
Since we weren't using it for anything, and we always failed if it was
set, we're allowed to change the future semantics of setting it.
2010-07-22 14:44:24 +02:00