evdns.c


Log

Author Commit Date CI Message
Nick Mathewson a220a081 2012-02-15T21:07:44 Merge remote-tracking branch 'github/21_fast_syscalls'
Nick Mathewson a63ed161 2012-02-15T20:26:52 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson bec50680 2012-02-15T20:12:32 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.
Nick Mathewson 539466e5 2012-02-10T17:33:50 Merge remote-tracking branch 'origin/patches-2.0' Conflicts: Makefile.am WIN32-Code/event2/event-config.h configure.in
Nick Mathewson e49e2891 2012-02-10T17:29:53 Update copyright notices to 2012
Nick Mathewson 713e570a 2012-02-10T16:32:50 Save some syscalls when creating evdns sockets
Nick Mathewson 032aac15 2012-02-01T14:57:44 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson d6094b16 2012-02-01T14:56:43 evdns: fix a bug in circular-queue implementation found by Wang Qin
Nick Mathewson fc1a2514 2011-10-19T22:20:15 Merge remote-tracking branch 'origin/patches-2.0'
Leonid Evdokimov 21a08d68 2011-10-19T22:38:37 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.
Nick Mathewson b3bc77b6 2011-10-03T12:54:35 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson 39c0cf7c 2011-10-03T12:49:02 Fix some "value never used" warnings with gcc 4.6.1
Nick Mathewson 38674d4a 2011-09-12T15:46:54 Merge remote-tracking branch 'origin/patches-2.0'
Leonid Evdokimov 94fba5b9 2011-08-10T15:58:47 Add DNS_ERR_NODATA error code to handle empty replies.
Nick Mathewson 804f77fb 2011-09-01T17:39:37 Merge remote-tracking branch 'origin/patches-2.0'
Leonid Evdokimov f72e8f66 2011-08-31T00:56:45 DNS: add ttl for negative answers using RFC 2308 idea.
Nick Mathewson d7451b05 2011-08-15T11:14:57 Merge remote-tracking branch 'origin/patches-2.0'
Leonid Evdokimov aff6ba15 2011-08-11T03:24:06 Fix request_finished memory leak with debugging turned on.
Nick Mathewson 9f560bfa 2011-05-25T19:50:56 Use "_WIN32", not WIN32: it's standard and we don't need to fake it This patch was automatically generated with perl. Based on a patch by Peter Rosin.
Nick Mathewson 9155b095 2011-05-25T16:52:50 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson 06a714ff 2011-05-25T16:51:25 Fix new warnings from GCC 4.6
Nick Mathewson a9fe47f0 2011-05-23T17:50:45 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson 74760f18 2011-05-23T17:45:14 Fix a bug that prevented us from configuring IPv6 nameservers.
Nick Mathewson 614a1712 2011-04-22T23:46:25 Merge remote-tracking branch 'origin/patches-2.0' Conflicts: evthread.c
Sebastian Hahn 5208544e 2011-03-14T04:24:33 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.
Nick Mathewson 34631be0 2011-04-21T17:36:30 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson 364291e9 2011-04-21T17:11:41 Handle calloc failure in evdns. (Found by Dave Hart)
Nick Mathewson 169eca7b 2011-04-21T13:38:29 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson 00e91b3c 2011-04-20T13:27:31 Fix a crash bug in evdns server circular list code Really, this should use a circleq. That's a change for 2.1, though.
Nick Mathewson d28fc528 2011-04-14T14:20:09 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson 3417f680 2011-04-13T11:20:30 Avoid a free(NULL) if out-of-memory in evdns_getaddrinfo. Found by Dave Hart
Nick Mathewson 8b0afe96 2011-01-12T21:41:58 Merge remote branch 'origin/patches-2.0'
Jardel Weyrich 666b0966 2010-12-18T01:07:27 Detect and handle more allocation failures.
Kevin Bowling 0915ca0a 2011-01-02T08:43:45 Include evconfig-private.h in internal files for great good.
Evan Jones fbe64f21 2010-12-02T10:26:12 Use relative includes instead of system includes consistently.
Nick Mathewson 7bcace2d 2010-11-22T21:02:34 Fix some irix compilation warnings spotted by Kevin Bowling
Nick Mathewson d51b2fc6 2010-11-19T12:14:18 Make evdns_getaddrinfo_cancel threadsafe
Nick Mathewson c7cfbcf4 2010-11-19T12:01:05 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.
Nick Mathewson abf01ed1 2010-11-19T11:33:48 Avoid double-invocation of user callback with EVUTIL_EAI_CANCEL
Nick Mathewson 49418612 2010-11-16T12:55:10 Use the US-English "canceled", not the UK "cancelled".
Nick Mathewson 5c8a59e8 2010-11-09T10:19:05 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'
Nick Mathewson 9ed30de7 2010-11-03T12:37:37 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.
Nick Mathewson ba014569 2010-11-02T12:42:35 Use the label_len local variable in evdns instead of recalculating it over and over
Nick Mathewson 545a6114 2010-11-01T13:59:04 Fix even more win64 warnings: buffer, event_tagging, http, evdns, evrpc
Nick Mathewson 5b7a3706 2010-10-05T14:29:48 Fix warnings on mingw with gcc 4.5
Nick Mathewson a8b7674c 2010-09-28T01:09:17 Merge remote branch 'github/signed_compare'
Nick Mathewson d49b5e33 2010-09-27T15:12:55 Do not search outside of the system directory for windows DLLs Hardens against some attacks.
Nick Mathewson 9c8db0f8 2010-09-23T22:45:55 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
Nick Mathewson 749128b2 2010-09-04T22:02:32 Merge remote branch 'github/win32_posix_underscore'
Nick Mathewson 19521436 2010-09-03T16:42:16 Expose a function to add a nameserver by sockaddr
Nick Mathewson e50c0fcc 2010-09-02T11:10:50 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.
Nick Mathewson d0b88433 2010-08-18T10:49:12 Set close-on-exec bit for filedescriptors created by dns subsystem. Based on patch for 1.4 by Ralf Schmitt.
Nick Mathewson ec347b92 2010-07-07T16:45:03 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.
Nick Mathewson 5fa30d2b 2010-08-06T17:13:27 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.
Nick Mathewson cc2379d2 2010-07-26T14:48:32 Constify a couple of arguments to evdns_server_request_add_*_reply
Nick Mathewson e1c1167c 2010-07-22T14:38:08 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.
Nick Mathewson 7e87a599 2010-07-21T14:33:42 Stop asserting when asked for a (unsupported) TCP dns port. Just return NULL.
Nick Mathewson 899b0a39 2010-05-24T15:24:03 Use generic win32 interfaces, not ASCII-only ones, where possible.
Nick Mathewson b14f151b 2010-05-18T17:27:06 If no evdns request can be launched, return NULL, not a handle Some of our evdns code was willing to return an evdns_request with handle->current_req set to NULL. Really, those cases should just return NULL.
Nick Mathewson b1c79500 2010-04-23T14:42:25 Make evdns logging threadsafe The old logging code was littered with places where we stored messages in static char[] fields. This is fine in a single-threaded program, but if you ever tried to log evdns messages from two threads at once, you'd hit a race. This patch also refactors evdns's debug_ntop function into a more useful evutil_sockaddr_port_format() function, with unit tests.
Nick Mathewson ceefbe87 2010-04-23T14:04:03 Add a comment to explain why evdns_request is now separte from request
Christopher Davis 67072f3c 2010-04-22T21:46:05 Assert for valid requests as necessary. A valid request has an associated handle, and the handle must point to the request.
Christopher Davis a6258400 2010-04-21T22:20:10 Free search state when finished searching to avoid an infinite loop.
Christopher Davis beaa14a4 2010-04-21T22:01:59 Move domain search state to evdns_request. It doesn't seem to make sense to copy the state to each new request in the search.
Christopher Davis 15bb82d6 2010-04-21T21:21:21 Ensure that evdns_request is a persistent handle. When searching is enabled, evdns may make multiple requests before calling the user callback with the result. This is a problem because the same evdns_request handle is not retained for each search request, so the user cannot reliably cancel the request. This patch attempts to ensure that evdns_request persists accross search requests.
Sebastian Sjöberg 899c1dcc 2010-04-14T15:42:57 Replace EVUTIL_CLOSESOCKET macro with a function The EVUTIL_CLOSESOCKET() macro required you to include unistd.h in your source for POSIX. We might as well turn it into a function: an extra function call is going to be cheap in comparison with the system call. We retain the EVUTIL_CLOSESOCKET() macro as an alias for the new evutil_closesocket() function. (commit message from email by Nick and Sebastian)
Nick Mathewson 859af677 2010-03-13T00:53:54 Free evdns_base->req_heads on evdns_base_free It looks like when we moved from one big inflight-requests list to an n-heads structure, we didn't make evdns_base_free() free the array of heads. This patch should fix that. Found with valgrind
Nick Mathewson b2f2be6e 2010-03-10T16:25:16 Make evdns use the regular logging system by default Once, for reasons that made sense at the time, we had evdns.c use its own logging subsystem with two levels, "warn" and "debug". This leads to problems, since setting a log handler for Libevent wouldn't actually trap these messages, since they weren't on by default, and since some of the warns should really be msgs. This patch changes the default behavior of evdns.c to log to event_(debugx,warnx,msgx) by default, and adds a new (internal-use-only) log level of EVDNS_LOG_MSG. Programs that set a evdns logging function will see no change. Programs that don't will now see evdns warnings reported like other warnings.
Nick Mathewson 2c2618d8 2010-03-05T13:00:15 more whitespace normalization
Nick Mathewson 4faeaea9 2010-02-19T03:39:50 Clean up formatting: function/keyword spacing consistency. - Keywords always have a space before a paren. Functions never do. - No more than 3 blank lines in a row.
Nick Mathewson e5bbd40a 2010-02-18T17:41:15 Clean up formatting: use tabs, not 8-spaces, to indent.
Nick Mathewson d4de062e 2010-02-10T17:19:18 Add an arc4random implementation for use by evdns Previously, evdns was at the mercy of the user for providing a good entropy source; without one, it would be vulnerable to various active attacks. This patch adds a port of OpenBSD's arc4random() calls to Libevent [port by Chris Davis], and wraps it up a little bit so we can use it more safely.
Nick Mathewson 1dd7e6dc 2010-02-05T01:16:23 Remove the 'flags' argument from evdns_base_set_option() The 'flags' argument made sense when passed to evdns_(base_)?parse_resolv_conf when it said which parts of the resolv.conf file to obey. But for evdns_set_option(), it was really silly, since you wouldn't be calling evdns_set_option() unless you actually wanted to set the option. Its meaning was basically, "set this to DNS_OPTIONS_ALL unless you want a funny surprise." evdns_base_set_option was new in 2.0.1-alpha, so we aren't committed to keeping it source-compatible.
Nick Mathewson a7a94310 2010-02-03T23:49:22 Fix some additional -DUNICODE issues on win32. Brodie's patch didn't catch the ones that were new since 1.4.
Brodie Thiesfield 000a33ec 2010-02-03T23:27:40 Make Libevent 1.4.12 build on win32 with Unicode enabled. This patch fixes calls to the win32 api to explicitly call the char* versions of the functions. This fixes build failures when libevent is built with the UNICODE define.
Nick Mathewson da6135e3 2010-02-03T02:09:19 Reduce windows header includes in our own headers. It turns out that absolutely everything that was including windows.h was doing so needlessly; our headers don't need it, so we should just include winsock2.h (since that's where struct timeval is defined). Pre-2.0 code will use the old headers, which include windows.h for them, so we aren't breaking source compatibility with 1.4. This solves the bug where we were leaving WIN32_LEAN_AND_MEAN defined, in roughly the same way that buying an automobile solves the question of what to give your coachman for boxing day.
Nick Mathewson 439aea0d 2010-01-25T14:07:01 Try to untangle the logic in server_port_flush(). The logic that prevented the first loop in this function from being infinite was rather confusing and hard to follow. It seems to confuse some automatic analysis tools as well as me. Let's try to replace it with something more comprehensible.
Nick Mathewson a19b4a05 2010-01-25T13:38:07 Call event_debug_unassign on internal events I don't expect that many users will be so religious about calling unassign, but we need to be so that it's at least possible to use debug mode without eating memory.
Nick Mathewson e2ca403f 2010-01-23T16:23:45 Make it compile under gcc --std=c89.
Nick Mathewson ff3f6cd4 2010-01-22T16:14:49 Check more internal event_add() calls for failure Most of these should be unable to fail, since adding a timeout generally always works. Still, it's better not to try to be "too smart for our own good here." There are some remaining event_add() calls that I didn't add checks for; I've marked those with "XXXX" comments.
Nick Mathewson 8d4aaf90 2010-01-20T12:56:54 Don't use a bind address for nameservers on loopback If the user sets a bind address to use for nameservers, and a nameserver happens to be on 127.0.0.1, the nameserver will generally fail. This patch alters this behavior so that the bind address is only applied when the nameserver is on a non-loopback address.
Nick Mathewson 66c02c78 2010-01-08T04:02:19 Look at the proper /etc/hosts file on windows. This is harder than it might initially seem, since the proper filename depends on what the admin has decided to call the windows system directory, which for all we know might be Q:\tralfamidore\slartibartfast. And of course, this being windows, there are twelve ways to do it, where you can pick a nice one or a portable one, but not a really nice portable one.
Nick Mathewson 72dd6667 2009-12-07T17:21:41 evdns_getaddrinfo() now supports the /etc/hosts file. The regular blocking evutil_getaddrinfo() already supported /etc/hosts by falling back to getaddrinfo() or gethostbyname(). But evdns_getaddrinfo() had no such facility. Now it does. The data structure here isn't very clever. I guess people with huge /etc/hosts files will either need to get out of the 1980s, or submit a patch to this code so that it uses a hashtable instead of a linked list. Includes basic unit tests.
Jardel Weyrich 0546ce11 2009-12-30T05:03:54 Eradicated the last free() call. Let mm_free() take care of deallocation.
Nick Mathewson 1e56a32d 2009-12-29T16:04:16 Make the initial nameserver probe timeout configurable. When we decide that a nameserver is down, we stop sending queries to it, except to periodically probe it to see if it has come back up. Our previous probe sechedule was an ad-hoc and hard-wired "10 seconds, one minute, 5 minues, 15 minutes, 1 hour, 1 hour, 1 hour...". There was nothing wrong with having it be ad-hoc, but making it hard-wired served no good purpose. Now the user can set the initial timeout via a new "initial-probe-timeout:" option; future timeouts back off by a factor of 3 on every failure to a maximum of 1 hour. As a side-benefit, this lets us cut the runtime of the dns/retry test from about 40 seconds to about 3 seconds. Faster unit tests are always a good thing.
Nick Mathewson ee4953f8 2009-12-29T16:03:30 Fix the code that allowed DNS options to not end with : We tried to fix this in 0.2.0.3-alpha, but our fix was buggy.
unknown c51bb3c3 2009-12-21T16:36:40 Fix a few locking issues on windows.
Nick Mathewson 2b7abf03 2009-12-04T13:49:27 Merge commit 'niels/dnscrash'
Yasuoka Masahiko 6c7c5799 2009-12-04T10:44:46 Fix a crash when reading badly formatted resolve.conf; from Yasuoka Masahiko
Nick Mathewson 0cd3bb9f 2009-11-27T17:22:19 Improved optional lock debugging. There were a couple of places in the code where we manually kept lock counts to make sure we never accessed resources without holding a lock, and that we never released a lock we didn't have. The lock-debugging code already puts counts on _every_ lock when lock debugging is enabled, so there is no need to keep these counts around otherwise. This patch rewrites the ASSERT_FOO_LOCKED macros to all use a common EVLOCK_ASSERT_LOCKED(). We also teach the lock debugging code to keep track of who exactly holds each lock, so that EVLOCK_ASSERT_LOCKED() means "locked by this thread."
Zhuang Yuyao 2df1f82b 2009-11-27T16:02:49 Fix an evdns lock violation. Original message: evdns contains a bug related to thread lock. enable thread lock by evthread_use_pthreads() will cause successive evdns_base_resolve_ipv4() (and other resolve functions i think) to hang on EVDNS_LOCK(base) after one or several successful call to evdns_base_resolve_ipv4().
Nick Mathewson 76cd2b70 2009-11-27T16:44:47 Stop passing EVTHREAD_READ and EVTHREAD_WRITE to non-rw locks. Previously, our default lock model kind of assumed that every lock was potentially a read-write lock. This was a poor choice, since read-write locks are far more expensive than regular locks, and so the lock API should only use them when we can actually take advantage of them. Neither our pthreads or win32 lock implementation provided rw locks. Now that we have a way (not currently used!) to indicate that we really want a read-write lock, we shouldn't actually say "lock this for reading" or "lock this for writing" unless we mean it.
Nick Mathewson 347952ff 2009-11-27T15:20:43 Revise the locking API: deprecate the old locking callbacks and add trylock. Previously, there was no good way to request different kinds of lock (say, read/write vs writeonly or recursive vs nonrecursive), or for a lock function to signal failure (which would be important for a trylock mode). This patch revises the lock API to be a bit more useful. The older lock calls are still supported for now. We also add a debugging mode to catch common errors in using the locking APIs.
Nick Mathewson 91fe23fc 2009-11-20T15:46:04 Tolerate code that returns from a fatal_cb. Also, replace more abort() calls with EVUTIL_ASSERT() or event_errx.
Nick Mathewson 767eb70f 2009-11-18T21:16:33 Fix compilation with threading disabled. svn:r1546
Nick Mathewson 86f57420 2009-11-16T22:25:46 Add two implementations of getaddrinfo: one blocking and one nonblocking. The entry points are evutil_getaddrinfo and evdns_getaddrinfo respectively. There are fairly extensive unit tests. I believe this code conforms to RFC3493 pretty closely, but there are probably more issues. It should get tested on more platforms. This code means we can dump the well-intentioned but weirdly-implemented bufferevent_evdns and evutil_resolve code. svn:r1537
Nick Mathewson 72bafc17 2009-11-16T22:23:55 Remove the stupid brokenness where DNS option names needed to end with a colon. svn:r1536
Nick Mathewson 18a8cfac 2009-11-15T19:00:12 Prefer calloc(a,b) to malloc(a*b). via openbsd. svn:r1531
Nick Mathewson e2b2de79 2009-11-15T18:59:48 Use arc4random() for dns transaction ids where available. Patch taken from OpenBSD svn:r1528
Nick Mathewson 784b8773 2009-11-06T21:46:57 We do not work any more without an event-config.h; stop pretending that it is meaningful to check for HAVE_CONFIG_H svn:r1516