Say "KBytes" rather than "KB" in the man page

(for various values of K), to further reduce confusion about whether
Tor counts in units of memory or fractions of units of memory. Fixes
bug 7054.
Allow a v4 link protocol for 4-byte circuit IDs.

Implements proposal 214.

Needs testing.
Add a pointless 2-byte memset in cell_pack

There is probably no code that can write the 2 bytes at the end of the
packed_cell_t when the cell is only a 512-byte cell, but let's not get
overconfident there.
Implement proposal-214 rules for CircID checking.
Wrapper function for the common rate-limited-log pattern.
Use log_fn_ratelim in a few places.
Fix memory leak in safe-cookie authentication code

Coverity spotted this. Bug 7816. Fix on 0.2.3.13-alpha.
Avoid leaking headers received from SSL proxy

Fixes part of 7816. Spotted by coverity. Fix on 0.2.2.1-alpha.
Fix various small leaks on error cases

Spotted by coverity, bug 7816, bugfix on various versions.
Fix a leak-on-error case in 0.2.4 spotted by coverity

This one hits if the snprintf() fails when we're writing our IPv6
exit policy. It's new in 0.2.4.7-alpha. Part of bug 7816.
Fix an impossible-in-normal-operation leaks in dirvote

Spotted by coverity; partial fix for 7816; bugfix on 0.2.0.5-alpha.
When we get an END cell before CONNECTED, don't report SOCKS success

Bug 7902; fix on 0.1.0.1-rc.
Adjust control_reason when adjusting reason (related to 7902)
When excluding nodes by country, exclude {??} and {A1} too

This is ticket 7706, reported by "bugcatcher."  The rationale here
is that if somebody says 'ExcludeNodes {tv}', then they probably
don't just want to block definitely Tuvaluan nodes: they also want
to block nodes that have unknown country, since for all they know
such nodes are also in Tuvalu.

This behavior is controlled by a new GeoIPExcludeUnknown autobool
option.  With the default (auto) setting, we exclude ?? and A1 if
any country is excluded.  If the option is 1, we add ?? and A1
unconditionally; if the option is 0, we never add them.

(Right now our geoip file doesn't actually seem to include A1: I'm
including it here in case it comes back.)

This feature only takes effect if you have a GeoIP file.  Otherwise
you'd be excluding every node.
Split smartlist_choose_node_by_bandwidth_weights

This is a minimal refactoring to expose the weighted bandwidth
calculations for each node so I can use them to see what fraction of
nodes, weighted by bandwidth, we have descriptors for.
Implement Path use bias accounting.

Path use bias measures how often we can actually succeed using the circuits we
actually try to use. It is a subset of path bias accounting, but it is
computed as a separate statistic because the rate of client circuit use may
vary depending on use case.
Roll back the path_state for circs if we detatch a stream.

An adversary could let the first stream request succeed (ie the resolve), but
then tag and timeout the remainder (via cell dropping), forcing them on new
circuits.

Rolling back the state will cause us to probe such circuits, which should lead
to probe failures in the event of such tagging due to either unrecognized
cells coming in while we wait for the probe, or the cipher state getting out
of sync in the case of dropped cells.
Don't immediately count cannibalized circs as used.

Since they use RELAY_EARLY (which can be seen by all hops on the path),
it's not safe to say they actually count as a successful use.

There are also problems with trying to allow them to finish extending due to
the circuit purpose state machine logic. It is way less complicated (and
possibly more semantically coherent) to simply wait until we actually try to
do something with them before claiming we 'used' them.

Also, we shouldn't call timed out circuits 'used' either, for semantic
consistency.
Remove a source of error during path bias scaling

If any circuits were opened during a scaling event, we were scaling attempts
and successes by different amounts. This leads to rounding error.

The fix is to record how many circuits are in a state that hasn't been fully
counted yet, and subtract that before scaling, and add it back afterwords.
Document path use bias options in the manpage.