commit 1aab5b6b391ca179d9acded9465ee4941ec4700b Merge: 9a6642f 16c5a62 Author: Nick Mathewson nickm@torproject.org Date: Wed Jul 13 12:12:16 2011 -0400
Merge remote-tracking branch 'public/bug1666'
Conflicts: doc/spec/socks-extensions.txt src/or/buffers.c src/or/config.c src/or/connection_edge.c
changes/bug1666 | 4 + src/or/buffers.c | 182 ++++++++++++++++------ src/or/buffers.h | 2 + src/or/config.c | 3 +- src/or/config.h | 2 + src/or/connection.c | 8 +- src/or/connection_edge.c | 23 ++-- src/or/or.h | 26 +++- src/test/test.c | 384 ++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 566 insertions(+), 68 deletions(-)
diff --cc src/or/buffers.c index 7312749,b7567bf..256b507 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@@ -1482,10 -1475,25 +1482,29 @@@ log_unsafe_socks_warning(int socks_prot socks_protocol, address, (int)port); }
+/** Do not attempt to parse socks messages longer than this. This value is + * actually significantly higher than the longest possible socks message. */ +#define MAX_SOCKS_MESSAGE_LEN 512 + + /** Return a new socks_request_t. */ + socks_request_t * + socks_request_new(void) + { + return tor_malloc_zero(sizeof(socks_request_t)); + } + + /** Free all storage held in the socks_request_t <b>req</b>. */ + void + socks_request_free(socks_request_t *req) + { + if (!req) + return; + tor_free(req->username); + tor_free(req->password); + memset(req, 0xCC, sizeof(socks_request_t)); + tor_free(req); + } + /** There is a (possibly incomplete) socks handshake on <b>buf</b>, of one * of the forms * - socks4: "socksheader username\0" diff --cc src/or/config.c index 4a9d2c9,d2dbdaa..cdf0122 --- a/src/or/config.c +++ b/src/or/config.c @@@ -547,44 -521,38 +547,43 @@@ static char *get_windows_conf_root(void #endif static void config_line_append(config_line_t **lst, const char *key, const char *val); -static void option_clear(config_format_t *fmt, or_options_t *options, - config_var_t *var); -static void option_reset(config_format_t *fmt, or_options_t *options, - config_var_t *var, int use_defaults); -static void config_free(config_format_t *fmt, void *options); +static void option_clear(const config_format_t *fmt, or_options_t *options, + const config_var_t *var); +static void option_reset(const config_format_t *fmt, or_options_t *options, + const config_var_t *var, int use_defaults); +static void config_free(const config_format_t *fmt, void *options); static int config_lines_eq(config_line_t *a, config_line_t *b); -static int option_is_same(config_format_t *fmt, - or_options_t *o1, or_options_t *o2, +static int option_is_same(const config_format_t *fmt, + const or_options_t *o1, const or_options_t *o2, const char *name); -static or_options_t *options_dup(config_format_t *fmt, or_options_t *old); -static int options_validate(or_options_t *old_options, or_options_t *options, +static or_options_t *options_dup(const config_format_t *fmt, + const or_options_t *old); +static int options_validate(or_options_t *old_options, + or_options_t *options, int from_setconf, char **msg); -static int options_act_reversible(or_options_t *old_options, char **msg); -static int options_act(or_options_t *old_options); -static int options_transition_allowed(or_options_t *old, or_options_t *new, +static int options_act_reversible(const or_options_t *old_options, char **msg); +static int options_act(const or_options_t *old_options); +static int options_transition_allowed(const or_options_t *old, + const or_options_t *new, char **msg); -static int options_transition_affects_workers(or_options_t *old_options, - or_options_t *new_options); -static int options_transition_affects_descriptor(or_options_t *old_options, - or_options_t *new_options); +static int options_transition_affects_workers( + const or_options_t *old_options, const or_options_t *new_options); +static int options_transition_affects_descriptor( + const or_options_t *old_options, const or_options_t *new_options); static int check_nickname_list(const char *lst, const char *name, char **msg); - static void config_register_addressmaps(const or_options_t *options);
static int parse_bridge_line(const char *line, int validate_only); +static int parse_client_transport_line(const char *line, int validate_only); static int parse_dir_server_line(const char *line, - authority_type_t required_type, + dirinfo_type_t required_type, int validate_only); static int validate_data_directory(or_options_t *options); -static int write_configuration_file(const char *fname, or_options_t *options); -static config_line_t *get_assigned_option(config_format_t *fmt, - void *options, const char *key, - int escape_val); -static void config_init(config_format_t *fmt, void *options); +static int write_configuration_file(const char *fname, + const or_options_t *options); +static config_line_t *get_assigned_option(const config_format_t *fmt, + const void *options, const char *key, + int escape_val); +static void config_init(const config_format_t *fmt, void *options); static int or_state_validate(or_state_t *old_options, or_state_t *options, int from_setconf, char **msg); static int or_state_load(void); @@@ -4430,8 -4313,8 +4429,8 @@@ get_torrc_fname(void /** Adjust the address map based on the MapAddress elements in the * configuration <b>options</b> */ - static void + void -config_register_addressmaps(or_options_t *options) +config_register_addressmaps(const or_options_t *options) { smartlist_t *elts; config_line_t *opt; diff --cc src/or/config.h index bc71191,db871d4..8a06f44 --- a/src/or/config.h +++ b/src/or/config.h @@@ -79,5 -76,7 +79,7 @@@ uint32_t get_effective_bwburst(const or or_options_t *options_new(void); #endif
-void config_register_addressmaps(or_options_t *options); ++void config_register_addressmaps(const or_options_t *options); + #endif
diff --cc src/or/connection_edge.c index 7516716,bff73d4..c19e8b7 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@@ -2144,7 -1882,8 +2144,8 @@@ connection_ap_handshake_process_socks(e { socks_request_t *socks; int sockshere; - or_options_t *options = get_options(); + const or_options_t *options = get_options(); + int had_reply = 0;
tor_assert(conn); tor_assert(conn->_base.type == CONN_TYPE_AP);
tor-commits@lists.torproject.org