199 Commits

Author SHA1 Message Date
Nick Mathewson
9f560bfa11 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.
2011-05-25 20:03:15 -04:00
Nick Mathewson
9155b09534 Merge remote-tracking branch 'origin/patches-2.0' 2011-05-25 16:52:50 -04:00
Nick Mathewson
06a714ffe4 Fix new warnings from GCC 4.6 2011-05-25 16:52:03 -04:00
Nick Mathewson
a9fe47f076 Merge remote-tracking branch 'origin/patches-2.0' 2011-05-23 17:50:45 -04:00
Nick Mathewson
74760f1864 Fix a bug that prevented us from configuring IPv6 nameservers. 2011-05-23 17:45:50 -04:00
Nick Mathewson
614a1712b7 Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	evthread.c
2011-04-22 23:46:25 -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
34631be00c Merge remote-tracking branch 'origin/patches-2.0' 2011-04-21 17:36:30 -04:00
Nick Mathewson
364291e9a9 Handle calloc failure in evdns. (Found by Dave Hart) 2011-04-21 17:11:41 -04:00
Nick Mathewson
169eca7b58 Merge remote-tracking branch 'origin/patches-2.0' 2011-04-21 13:38:29 -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
d28fc52815 Merge remote-tracking branch 'origin/patches-2.0' 2011-04-14 14:20:09 -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
Nick Mathewson
8b0afe96eb Merge remote branch 'origin/patches-2.0' 2011-01-12 21:41:58 -05:00
Jardel Weyrich
666b096691 Detect and handle more allocation failures. 2011-01-07 13:03:31 -05:00
Kevin Bowling
0915ca0aa6 Include evconfig-private.h in internal files for great good. 2011-01-02 08:43:45 -07: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
Nick Mathewson
7e87a599bb Stop asserting when asked for a (unsupported) TCP dns port. Just return NULL. 2010-07-21 14:33:42 +02:00
Nick Mathewson
899b0a39ab Use generic win32 interfaces, not ASCII-only ones, where possible. 2010-05-24 15:24:03 -04:00
Nick Mathewson
b14f151b42 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.
2010-05-18 17:27:06 -04:00
Nick Mathewson
b1c795007f 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.
2010-04-23 14:42:25 -04:00
Nick Mathewson
ceefbe8730 Add a comment to explain why evdns_request is now separte from request 2010-04-23 14:04:03 -04:00
Christopher Davis
67072f3c3b Assert for valid requests as necessary.
A valid request has an associated handle, and the handle must point
to the request.
2010-04-22 21:46:05 -07:00
Christopher Davis
a62584000a Free search state when finished searching to avoid an infinite loop. 2010-04-21 22:20:10 -07:00
Christopher Davis
beaa14a46f 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.
2010-04-21 22:01:59 -07:00
Christopher Davis
15bb82d690 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.
2010-04-21 21:21:21 -07:00
Sebastian Sjöberg
899c1dcc98 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)
2010-04-14 15:42:57 -04:00
Nick Mathewson
859af6772c 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
2010-03-13 00:53:54 -05:00
Nick Mathewson
b2f2be6edc 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.
2010-03-10 16:25:16 -05:00