From b181985a8f98c0ba15230912f059e1fcf7c626f1 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Tue, 21 Jun 2011 00:37:18 -0400 Subject: [PATCH 01/12] explain that the ./publish should happen soon after the scp otherwise you scp a tarball up but only one version of the website has it. --- doc/HACKING | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/doc/HACKING b/doc/HACKING index 7ff9c5f3c2..feeb05d028 100644 --- a/doc/HACKING +++ b/doc/HACKING @@ -456,7 +456,6 @@ interesting and understandable. 2.7) Run it through fmt to make it pretty. - 3) Compose a short release blurb to highlight the user-facing changes. Insert said release blurb into the ChangeLog stanza. If it's a stable release, add it to the ReleaseNotes file too. If we're adding @@ -472,15 +471,19 @@ or somebody to try building it on Windows. 6) Get at least two of weasel/arma/karsten to put the new version number in their approved versions list. -7) Sign and push the tarball to the website in the dist/ directory. Sign -and push the git tag. - (That's either "git tag -u tor-0.2.x.y-status", then - "git push origin tag tor-0.2.x.y-status". To sign the - tarball, "gpg -ba ". Put the files in - /srv/www-master.torproject.org/htdocs/dist/ on vescum.) +7) Sign the tarball, then sign and push the git tag: + gpg -ba + git tag -u tor-0.2.x.y-status + git push origin tag tor-0.2.x.y-status -8) Edit include/versions.wmi to note the new version. From your website -checkout, run ./publish to build and publish the website. +8) scp the tarball and its sig to the website in the dist/ directory +(i.e. /srv/www-master.torproject.org/htdocs/dist/ on vescum). Edit +include/versions.wmi to note the new version. From your website checkout, +run ./publish to build and publish the website. + +Try not to delay too much between scp'ing the tarball and running +./publish -- the website has multiple A records and your scp only sent +it to one of them. 9) Email Erinn and weasel (cc'ing tor-assistants) that a new tarball is up. This step should probably change to mailing more packagers. @@ -498,3 +501,4 @@ changelog to tor-talk or tor-announce. (We might be moving to faster announcements, but don't announce until the website is at least updated.) + From 8a55da57ed17dfb9cefe3193cbda53a15547630e Mon Sep 17 00:00:00 2001 From: Robert Ransom Date: Sun, 19 Jun 2011 01:25:51 -0700 Subject: [PATCH 02/12] Fix comment typo --- src/test/tinytest_demo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/tinytest_demo.c b/src/test/tinytest_demo.c index bd33cc37fa..4d2f588435 100644 --- a/src/test/tinytest_demo.c +++ b/src/test/tinytest_demo.c @@ -39,7 +39,7 @@ /* ============================================================ */ /* First, let's see if strcmp is working. (All your test cases should be - * functions declared to take a single void * as) an argument. */ + * functions declared to take a single void * as an argument.) */ void test_strcmp(void *data) { From d7254bea11a0fc2685cc2ea24fb57d2ab3945b2f Mon Sep 17 00:00:00 2001 From: Robert Ransom Date: Sun, 19 Jun 2011 01:28:40 -0700 Subject: [PATCH 03/12] Fix minor comment issues --- src/common/compat.c | 2 +- src/or/connection.c | 6 +++--- src/or/or.h | 6 +++--- src/test/Makefile.am | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/common/compat.c b/src/common/compat.c index 9377959eb4..c9839255d4 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -415,7 +415,7 @@ tor_vasprintf(char **strp, const char *fmt, va_list args) * * This function is not timing-safe. * - * Requires that nlen be greater than zero. + * Requires that nlen be greater than zero. */ const void * tor_memmem(const void *_haystack, size_t hlen, diff --git a/src/or/connection.c b/src/or/connection.c index a9e3a74ed6..b2412a2a34 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -2751,15 +2751,15 @@ connection_outbuf_too_full(connection_t *conn) return (conn->outbuf_flushlen > 10*CELL_PAYLOAD_SIZE); } -/** Try to flush more bytes onto conn-\>s. +/** Try to flush more bytes onto conn-\>s. * * This function gets called either from conn_write() in main.c * when poll() has declared that conn wants to write, or below * from connection_write_to_buf() when an entire TLS record is ready. * - * Update conn-\>timestamp_lastwritten to now, and call flush_buf + * Update conn-\>timestamp_lastwritten to now, and call flush_buf * or flush_buf_tls appropriately. If it succeeds and there are no more - * more bytes on conn->outbuf, then call connection_finished_flushing + * more bytes on conn-\>outbuf, then call connection_finished_flushing * on it too. * * If force, then write as many bytes as possible, ignoring bandwidth diff --git a/src/or/or.h b/src/or/or.h index 97fecd1500..1909887bbd 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2318,14 +2318,14 @@ typedef struct or_circuit_t { cell_ewma_t p_cell_ewma; } or_circuit_t; -/** Convert a circuit subtype to a circuit_t.*/ +/** Convert a circuit subtype to a circuit_t. */ #define TO_CIRCUIT(x) (&((x)->_base)) -/** Convert a circuit_t* to a pointer to the enclosing or_circuit_t. Asserts +/** Convert a circuit_t* to a pointer to the enclosing or_circuit_t. Assert * if the cast is impossible. */ static or_circuit_t *TO_OR_CIRCUIT(circuit_t *); /** Convert a circuit_t* to a pointer to the enclosing origin_circuit_t. - * Asserts if the cast is impossible. */ + * Assert if the cast is impossible. */ static origin_circuit_t *TO_ORIGIN_CIRCUIT(circuit_t *); static INLINE or_circuit_t *TO_OR_CIRCUIT(circuit_t *x) diff --git a/src/test/Makefile.am b/src/test/Makefile.am index 546fa2f4b7..904719d94b 100644 --- a/src/test/Makefile.am +++ b/src/test/Makefile.am @@ -8,7 +8,7 @@ AM_CPPFLAGS = -DSHARE_DATADIR="\"$(datadir)\"" \ -I"$(top_srcdir)/src/or" # -L flags need to go in LDFLAGS. -l flags need to go in LDADD. -# This seems to matter nowhere but on windows, but I assure you that it +# This seems to matter nowhere but on Windows, but I assure you that it # matters a lot there, and is quite hard to debug if you forget to do it. test_SOURCES = \ From 2b5ebc70973b1c0dd62201908632733c0953a4ec Mon Sep 17 00:00:00 2001 From: Robert Ransom Date: Wed, 22 Jun 2011 13:47:32 -0700 Subject: [PATCH 04/12] Improve documentation of smartlist_split_string --- src/common/container.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/container.c b/src/common/container.c index da44b7fe68..1515c387ad 100644 --- a/src/common/container.c +++ b/src/common/container.c @@ -338,7 +338,8 @@ smartlist_insert(smartlist_t *sl, int idx, void *val) /** * Split a string str along all occurrences of sep, - * adding the split strings, in order, to sl. + * appending the (newly allocated) split strings, in order, to + * sl. Return the number of strings added to sl. * * If flags&SPLIT_SKIP_SPACE is true, remove initial and * trailing space from each entry. @@ -347,7 +348,7 @@ smartlist_insert(smartlist_t *sl, int idx, void *val) * If flags&SPLIT_STRIP_SPACE is true, strip spaces from each * split string. * - * If max>0, divide the string into no more than max pieces. If + * If max\>0, divide the string into no more than max pieces. If * sep is NULL, split on any sequence of horizontal space. */ int From cb1b20dbad2ee346a814b30d5dc72a3dc93069e5 Mon Sep 17 00:00:00 2001 From: Robert Ransom Date: Thu, 23 Jun 2011 15:10:11 -0700 Subject: [PATCH 05/12] Fix minor comment issues --- src/or/circuitbuild.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 6d7e71194e..1140f3314e 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -1501,7 +1501,7 @@ get_unique_circ_id_by_conn(or_connection_t *conn) } /** If verbose is false, allocate and return a comma-separated list of - * the currently built elements of circuit_t. If verbose is true, also + * the currently built elements of circ. If verbose is true, also * list information about link status in a more verbose format using spaces. * If verbose_names is false, give nicknames for Named routers and hex * digests for others; if verbose_names is true, use $DIGEST=Name style @@ -1590,7 +1590,7 @@ circuit_list_path_impl(origin_circuit_t *circ, int verbose, int verbose_names) } /** If verbose is false, allocate and return a comma-separated - * list of the currently built elements of circuit_t. If + * list of the currently built elements of circ. If * verbose is true, also list information about link status in * a more verbose format using spaces. */ @@ -1601,7 +1601,7 @@ circuit_list_path(origin_circuit_t *circ, int verbose) } /** Allocate and return a comma-separated list of the currently built elements - * of circuit_t, giving each as a verbose nickname. + * of circ, giving each as a verbose nickname. */ char * circuit_list_path_for_controller(origin_circuit_t *circ) @@ -1610,7 +1610,7 @@ circuit_list_path_for_controller(origin_circuit_t *circ) } /** Log, at severity severity, the nicknames of each router in - * circ's cpath. Also log the length of the cpath, and the intended + * circ's cpath. Also log the length of the cpath, and the intended * exit point. */ void @@ -1622,7 +1622,7 @@ circuit_log_path(int severity, unsigned int domain, origin_circuit_t *circ) } /** Tell the rep(utation)hist(ory) module about the status of the links - * in circ. Hops that have become OPEN are marked as successfully + * in circ. Hops that have become OPEN are marked as successfully * extended; the _first_ hop that isn't open (if any) is marked as * unable to extend. */ From 53f87a89f00d075bdc81c2c468e844f3132ef953 Mon Sep 17 00:00:00 2001 From: Robert Ransom Date: Fri, 24 Jun 2011 15:12:45 -0700 Subject: [PATCH 06/12] Correct a comment --- src/or/circuitlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index 8534c38075..e9cc9eb1f4 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -866,7 +866,7 @@ circuit_unlink_all_from_or_conn(or_connection_t *conn, int reason) } /** Return a circ such that: - * - circ-\>rend_data-\>query is equal to rend_query, and + * - circ-\>rend_data-\>onion_address is equal to rend_query, and * - circ-\>purpose is equal to purpose. * * Return NULL if no such circuit exists. From 93d52f6739d3bb184575aa53eab1562d2c80ee57 Mon Sep 17 00:00:00 2001 From: Robert Ransom Date: Sat, 25 Jun 2011 15:02:11 -0700 Subject: [PATCH 07/12] Add BUILDTIMEOUT_SET to the result of GETINFO events/names --- changes/bug3465-022 | 6 ++++++ src/or/control.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changes/bug3465-022 diff --git a/changes/bug3465-022 b/changes/bug3465-022 new file mode 100644 index 0000000000..2d226162aa --- /dev/null +++ b/changes/bug3465-022 @@ -0,0 +1,6 @@ + o Minor bugfixes: + + - Add BUILDTIMEOUT_SET to the list returned by the 'GETINFO + events/names' control-port command. Bugfix on 0.2.2.9-alpha; + fixes part of bug 3465. + diff --git a/src/or/control.c b/src/or/control.c index 82017bd1d4..da0a95da15 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -1380,7 +1380,8 @@ getinfo_helper_misc(control_connection_t *conn, const char *question, *answer = tor_strdup("CIRC STREAM ORCONN BW DEBUG INFO NOTICE WARN ERR " "NEWDESC ADDRMAP AUTHDIR_NEWDESCS DESCCHANGED " "NS STATUS_GENERAL STATUS_CLIENT STATUS_SERVER " - "GUARD STREAM_BW CLIENTS_SEEN NEWCONSENSUS"); + "GUARD STREAM_BW CLIENTS_SEEN NEWCONSENSUS " + "BUILDTIMEOUT_SET"); } else if (!strcmp(question, "features/names")) { *answer = tor_strdup("VERBOSE_NAMES EXTENDED_EVENTS"); } else if (!strcmp(question, "address")) { From d25feadebbf05d6fce55cfee1e3c8f928903f543 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 1 Jul 2011 12:36:33 -0400 Subject: [PATCH 08/12] Fix insanely large stack_allocation in log_credential_status I'm not one to insist on C's miserly stack limits, but allocating a 256K array on the stack is too much even for me. Bugfix on 0.2.1.7-alpha. Found by coverity. Fixes CID # 450. --- changes/cid_450 | 5 +++++ src/common/compat.c | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 changes/cid_450 diff --git a/changes/cid_450 b/changes/cid_450 new file mode 100644 index 0000000000..2045fca239 --- /dev/null +++ b/changes/cid_450 @@ -0,0 +1,5 @@ + o Minor bugfixes: + - Don't stack-allocate the list of supplementary GIDs when we're + about to log them. Stack-allocating NGROUPS_MAX gid_t elements + could take up to 256K, which is way too much stack. Found by + Coverity; CID #450. Bugfix on 0.2.1.7-alpha. diff --git a/src/common/compat.c b/src/common/compat.c index 39651084a0..9533c115b6 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -1080,7 +1080,8 @@ log_credential_status(void) /* Read, effective and saved GIDs */ gid_t rgid, egid, sgid; /* Supplementary groups */ - gid_t sup_gids[NGROUPS_MAX + 1]; + gid_t *sup_gids = NULL; + int sup_gids_size; /* Number of supplementary groups */ int ngids; @@ -1126,9 +1127,19 @@ log_credential_status(void) #endif /* log supplementary groups */ - if ((ngids = getgroups(NGROUPS_MAX + 1, sup_gids)) < 0) { + sup_gids_size = 64; + sup_gids = tor_malloc(sizeof(gid_t) * 64); + while ((ngids = getgroups(sup_gids_size, sup_gids)) < 0 && + errno == EINVAL && + sup_gids_size < NGROUPS_MAX) { + sup_gids_size *= 2; + sup_gids = tor_realloc(sup_gids, sizeof(gid_t) * sup_gids_size); + } + + if (ngids < 0) { log_warn(LD_GENERAL, "Error getting supplementary GIDs: %s", strerror(errno)); + tor_free(sup_gids); return -1; } else { int i, retval = 0; @@ -1158,6 +1169,7 @@ log_credential_status(void) tor_free(cp); }); smartlist_free(elts); + tor_free(sup_gids); return retval; } From 359a30d52e01e6413a052f03b7067c40b10336d2 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 1 Jul 2011 12:46:26 -0400 Subject: [PATCH 09/12] Add a changelog entry for cid30 fix. --- changes/memleak_rendcache | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changes/memleak_rendcache diff --git a/changes/memleak_rendcache b/changes/memleak_rendcache new file mode 100644 index 0000000000..93b1f6141b --- /dev/null +++ b/changes/memleak_rendcache @@ -0,0 +1,4 @@ + o Minor bugfixes: + - Fix a memory leak when receiving a descriptor for a hidden + service we didn't ask for. Found by Coverity; CID#30. Bugfix on + 0.2.2.26-beta. From 46297bc7bd86826fa79195f36059ce408ef45b6c Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 1 Jul 2011 11:52:39 -0400 Subject: [PATCH 10/12] Fix a rare memory leak in rend_cache_store When we rejected a descriptor for not being the one we wanted, we were letting the parsed descriptor go out of scope. Found by Coverity; CID # 30. Bugfix on 0.2.1.26. (No changes file yet, since this is not in any 0.2.1.x release.) --- src/or/rendcommon.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c index 8727a70c2e..e0c101e1ee 100644 --- a/src/or/rendcommon.c +++ b/src/or/rendcommon.c @@ -1077,6 +1077,7 @@ rend_cache_store(const char *desc, size_t desc_len, int published, log_warn(LD_REND, "Received service descriptor for service ID %s; " "expected descriptor for service ID %s.", query, safe_str(service_id)); + rend_service_descriptor_free(parsed); return -2; } now = time(NULL); From 959da6b7f2b5ed63426fd12a9046ac06033f6db1 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 1 Jul 2011 12:06:54 -0400 Subject: [PATCH 11/12] Use strlcpy in create_unix_sockaddr() Using strncpy meant that if listenaddress were ever >= sizeof(sockaddr_un.sun_path), we would fail to nul-terminate sun_path. This isn't a big deal: we never read sun_path, and the kernel is smart enough to reject the sockaddr_un if it isn't nul-terminated. Nonetheless, it's a dumb failure mode. Instead, we should reject addresses that don't fit in sockaddr_un.sun_path. Coverity found this; it's CID 428. Bugfix on 0.2.0.3-alpha. --- changes/cid_428 | 5 +++++ src/or/connection.c | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 changes/cid_428 diff --git a/changes/cid_428 b/changes/cid_428 new file mode 100644 index 0000000000..cb0fc8c2b2 --- /dev/null +++ b/changes/cid_428 @@ -0,0 +1,5 @@ + o Minor bugfixes: + - Always NUL-terminate the sun_path field of a sockaddr_un before + passing it to the kernel. (Not a security issue: kernels are + smart enough to reject bad sockaddr_uns.) Found by Coverity; CID + # 428. Bugfix on Tor 0.2.0.3-alpha. diff --git a/src/or/connection.c b/src/or/connection.c index 4869a2439a..2897fe10a1 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -804,7 +804,13 @@ create_unix_sockaddr(const char *listenaddress, char **readable_address, sockaddr = tor_malloc_zero(sizeof(struct sockaddr_un)); sockaddr->sun_family = AF_UNIX; - strncpy(sockaddr->sun_path, listenaddress, sizeof(sockaddr->sun_path)); + if (strlcpy(sockaddr->sun_path, listenaddress, sizeof(sockaddr->sun_path)) + >= sizeof(sockaddr->sun_path)) { + log_warn(LD_CONFIG, "Unix socket path '%s' is too long to fit.", + escaped(listenaddress)); + tor_free(sockaddr); + return NULL; + } if (readable_address) *readable_address = tor_strdup(listenaddress); From bc91cb6e459042e11be11e50050ac086fdcb33dd Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 1 Jul 2011 12:14:44 -0400 Subject: [PATCH 12/12] Use strlcpy when copying node IDs into measured_bw_line_t We were using strncpy before, which isn't our style for stuff like this. This isn't a bug, though: before calling strncpy, we were checking that strlen(src) was indeed == HEX_DIGEST_LEN, which is less than sizeof(dst), so there was no way we could fail to NUL-terminate. Still, strncpy(a,b,sizeof(a)) is an idiom that we ought to squash everyplace. Fixes CID #427. --- src/or/dirserv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/or/dirserv.c b/src/or/dirserv.c index d114d8654e..7df9a2fcaa 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -2415,7 +2415,7 @@ measured_bw_line_parse(measured_bw_line_t *out, const char *orig_line) tor_free(line); return -1; } - strncpy(out->node_hex, cp, sizeof(out->node_hex)); + strlcpy(out->node_hex, cp, sizeof(out->node_hex)); got_node_id=1; } } while ((cp = tor_strtok_r(NULL, " \t", &strtok_state)));