Merge branch 'maint-0.2.2' into release-0.2.2
This commit is contained in:
commit
975dd009ec
|
@ -0,0 +1,3 @@
|
||||||
|
o Documentation fixes:
|
||||||
|
- Clarify the behavior of MaxCircuitDirtiness with hidden service
|
||||||
|
circuits. Fix for issue 5259.
|
|
@ -0,0 +1,8 @@
|
||||||
|
o Minor bugfixes:
|
||||||
|
- Correct parsing of certain date types in parse_http_time().
|
||||||
|
Without this patch, If-Modified-Since would behave
|
||||||
|
incorrectly. Fix for bug 5346; bugfix on 0.2.0.2-alpha. Patch from
|
||||||
|
Esteban Manchado Velázques.
|
||||||
|
- Reject out-of-range times like 23:59:61. Fix for bug 5346;
|
||||||
|
bugfix on 0.0.8pre3.
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
o Minor bugfixes (controller):
|
||||||
|
- Fix a NULL-pointer derefernce on a badly formed
|
||||||
|
SETCIRCUITPURPOSE command. Found by mikeyc. Fixes bug 5796;
|
||||||
|
bugfix on 0.2.2.9-alpha.
|
|
@ -0,0 +1,3 @@
|
||||||
|
o Minor features:
|
||||||
|
- Update to the May 1 2012 Maxmind GeoLite Country database.
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
o Minor bugfixes:
|
||||||
|
- If we hit the error case where routerlist_insert() replaces an
|
||||||
|
existing (old) server descriptor, make sure to remove that
|
||||||
|
server descriptor from the old_routers list. Fix related to bug
|
||||||
|
1776. Bugfix on 0.2.2.18-alpha.
|
|
@ -651,8 +651,9 @@ The following options are useful only for clients (that is, if
|
||||||
|
|
||||||
**MaxCircuitDirtiness** __NUM__::
|
**MaxCircuitDirtiness** __NUM__::
|
||||||
Feel free to reuse a circuit that was first used at most NUM seconds ago,
|
Feel free to reuse a circuit that was first used at most NUM seconds ago,
|
||||||
but never attach a new stream to a circuit that is too old. (Default: 10
|
but never attach a new stream to a circuit that is too old. For hidden
|
||||||
minutes)
|
services, this applies to the __last__ time a circuit was used, not the
|
||||||
|
first. (Default: 10 minutes)
|
||||||
|
|
||||||
**NodeFamily** __node__,__node__,__...__::
|
**NodeFamily** __node__,__node__,__...__::
|
||||||
The Tor servers, defined by their identity fingerprints or nicknames,
|
The Tor servers, defined by their identity fingerprints or nicknames,
|
||||||
|
|
|
@ -1268,7 +1268,7 @@ format_rfc1123_time(char *buf, time_t t)
|
||||||
tor_assert(tm.tm_wday >= 0);
|
tor_assert(tm.tm_wday >= 0);
|
||||||
tor_assert(tm.tm_wday <= 6);
|
tor_assert(tm.tm_wday <= 6);
|
||||||
memcpy(buf, WEEKDAY_NAMES[tm.tm_wday], 3);
|
memcpy(buf, WEEKDAY_NAMES[tm.tm_wday], 3);
|
||||||
tor_assert(tm.tm_wday >= 0);
|
tor_assert(tm.tm_mon >= 0);
|
||||||
tor_assert(tm.tm_mon <= 11);
|
tor_assert(tm.tm_mon <= 11);
|
||||||
memcpy(buf+8, MONTH_NAMES[tm.tm_mon], 3);
|
memcpy(buf+8, MONTH_NAMES[tm.tm_mon], 3);
|
||||||
}
|
}
|
||||||
|
@ -1298,7 +1298,8 @@ parse_rfc1123_time(const char *buf, time_t *t)
|
||||||
tor_free(esc);
|
tor_free(esc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (tm_mday > 31 || tm_hour > 23 || tm_min > 59 || tm_sec > 61) {
|
if (tm_mday < 1 || tm_mday > 31 || tm_hour > 23 || tm_min > 59 ||
|
||||||
|
tm_sec > 60) {
|
||||||
char *esc = esc_for_log(buf);
|
char *esc = esc_for_log(buf);
|
||||||
log_warn(LD_GENERAL, "Got invalid RFC1123 time %s", esc);
|
log_warn(LD_GENERAL, "Got invalid RFC1123 time %s", esc);
|
||||||
tor_free(esc);
|
tor_free(esc);
|
||||||
|
@ -1368,7 +1369,7 @@ int
|
||||||
parse_iso_time(const char *cp, time_t *t)
|
parse_iso_time(const char *cp, time_t *t)
|
||||||
{
|
{
|
||||||
struct tm st_tm;
|
struct tm st_tm;
|
||||||
unsigned int year=0, month=0, day=0, hour=100, minute=100, second=100;
|
unsigned int year=0, month=0, day=0, hour=0, minute=0, second=0;
|
||||||
if (tor_sscanf(cp, "%u-%2u-%2u %2u:%2u:%2u", &year, &month,
|
if (tor_sscanf(cp, "%u-%2u-%2u %2u:%2u:%2u", &year, &month,
|
||||||
&day, &hour, &minute, &second) < 6) {
|
&day, &hour, &minute, &second) < 6) {
|
||||||
char *esc = esc_for_log(cp);
|
char *esc = esc_for_log(cp);
|
||||||
|
@ -1377,7 +1378,7 @@ parse_iso_time(const char *cp, time_t *t)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (year < 1970 || month < 1 || month > 12 || day < 1 || day > 31 ||
|
if (year < 1970 || month < 1 || month > 12 || day < 1 || day > 31 ||
|
||||||
hour > 23 || minute > 59 || second > 61) {
|
hour > 23 || minute > 59 || second > 60) {
|
||||||
char *esc = esc_for_log(cp);
|
char *esc = esc_for_log(cp);
|
||||||
log_warn(LD_GENERAL, "ISO time %s was nonsensical", esc);
|
log_warn(LD_GENERAL, "ISO time %s was nonsensical", esc);
|
||||||
tor_free(esc);
|
tor_free(esc);
|
||||||
|
@ -1417,12 +1418,15 @@ parse_http_time(const char *date, struct tm *tm)
|
||||||
/* First, try RFC1123 or RFC850 format: skip the weekday. */
|
/* First, try RFC1123 or RFC850 format: skip the weekday. */
|
||||||
if ((cp = strchr(date, ','))) {
|
if ((cp = strchr(date, ','))) {
|
||||||
++cp;
|
++cp;
|
||||||
if (tor_sscanf(date, "%2u %3s %4u %2u:%2u:%2u GMT",
|
if (*cp != ' ')
|
||||||
|
return -1;
|
||||||
|
++cp;
|
||||||
|
if (tor_sscanf(cp, "%2u %3s %4u %2u:%2u:%2u GMT",
|
||||||
&tm_mday, month, &tm_year,
|
&tm_mday, month, &tm_year,
|
||||||
&tm_hour, &tm_min, &tm_sec) == 6) {
|
&tm_hour, &tm_min, &tm_sec) == 6) {
|
||||||
/* rfc1123-date */
|
/* rfc1123-date */
|
||||||
tm_year -= 1900;
|
tm_year -= 1900;
|
||||||
} else if (tor_sscanf(date, "%2u-%3s-%2u %2u:%2u:%2u GMT",
|
} else if (tor_sscanf(cp, "%2u-%3s-%2u %2u:%2u:%2u GMT",
|
||||||
&tm_mday, month, &tm_year,
|
&tm_mday, month, &tm_year,
|
||||||
&tm_hour, &tm_min, &tm_sec) == 6) {
|
&tm_hour, &tm_min, &tm_sec) == 6) {
|
||||||
/* rfc850-date */
|
/* rfc850-date */
|
||||||
|
@ -1447,18 +1451,20 @@ parse_http_time(const char *date, struct tm *tm)
|
||||||
|
|
||||||
month[3] = '\0';
|
month[3] = '\0';
|
||||||
/* Okay, now decode the month. */
|
/* Okay, now decode the month. */
|
||||||
|
/* set tm->tm_mon to dummy value so the check below fails. */
|
||||||
|
tm->tm_mon = -1;
|
||||||
for (i = 0; i < 12; ++i) {
|
for (i = 0; i < 12; ++i) {
|
||||||
if (!strcasecmp(MONTH_NAMES[i], month)) {
|
if (!strcasecmp(MONTH_NAMES[i], month)) {
|
||||||
tm->tm_mon = i+1;
|
tm->tm_mon = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tm->tm_year < 0 ||
|
if (tm->tm_year < 0 ||
|
||||||
tm->tm_mon < 1 || tm->tm_mon > 12 ||
|
tm->tm_mon < 0 || tm->tm_mon > 11 ||
|
||||||
tm->tm_mday < 0 || tm->tm_mday > 31 ||
|
tm->tm_mday < 1 || tm->tm_mday > 31 ||
|
||||||
tm->tm_hour < 0 || tm->tm_hour > 23 ||
|
tm->tm_hour < 0 || tm->tm_hour > 23 ||
|
||||||
tm->tm_min < 0 || tm->tm_min > 59 ||
|
tm->tm_min < 0 || tm->tm_min > 59 ||
|
||||||
tm->tm_sec < 0 || tm->tm_sec > 61)
|
tm->tm_sec < 0 || tm->tm_sec > 60)
|
||||||
return -1; /* Out of range, or bad month. */
|
return -1; /* Out of range, or bad month. */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
748
src/config/geoip
748
src/config/geoip
File diff suppressed because it is too large
Load Diff
|
@ -2389,6 +2389,10 @@ handle_control_setcircuitpurpose(control_connection_t *conn,
|
||||||
|
|
||||||
{
|
{
|
||||||
const char *purp = find_element_starting_with(args,1,"PURPOSE=");
|
const char *purp = find_element_starting_with(args,1,"PURPOSE=");
|
||||||
|
if (!purp) {
|
||||||
|
connection_write_str_to_buf("552 No purpose given\r\n", conn);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
new_purpose = circuit_purpose_from_string(purp);
|
new_purpose = circuit_purpose_from_string(purp);
|
||||||
if (new_purpose == CIRCUIT_PURPOSE_UNKNOWN) {
|
if (new_purpose == CIRCUIT_PURPOSE_UNKNOWN) {
|
||||||
connection_printf_to_buf(conn, "552 Unknown purpose \"%s\"\r\n", purp);
|
connection_printf_to_buf(conn, "552 Unknown purpose \"%s\"\r\n", purp);
|
||||||
|
|
|
@ -2815,6 +2815,13 @@ routerlist_insert(routerlist_t *rl, routerinfo_t *ri)
|
||||||
ri->cache_info.signed_descriptor_digest,
|
ri->cache_info.signed_descriptor_digest,
|
||||||
&(ri->cache_info));
|
&(ri->cache_info));
|
||||||
if (sd_old) {
|
if (sd_old) {
|
||||||
|
int idx = sd_old->routerlist_index;
|
||||||
|
sd_old->routerlist_index = -1;
|
||||||
|
smartlist_del(rl->old_routers, idx);
|
||||||
|
if (idx < smartlist_len(rl->old_routers)) {
|
||||||
|
signed_descriptor_t *d = smartlist_get(rl->old_routers, idx);
|
||||||
|
d->routerlist_index = idx;
|
||||||
|
}
|
||||||
rl->desc_store.bytes_dropped += sd_old->signed_descriptor_len;
|
rl->desc_store.bytes_dropped += sd_old->signed_descriptor_len;
|
||||||
sdmap_remove(rl->desc_by_eid_map, sd_old->extra_info_digest);
|
sdmap_remove(rl->desc_by_eid_map, sd_old->extra_info_digest);
|
||||||
signed_descriptor_free(sd_old);
|
signed_descriptor_free(sd_old);
|
||||||
|
|
|
@ -86,6 +86,76 @@ test_util_time(void)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_util_parse_http_time(void *arg)
|
||||||
|
{
|
||||||
|
struct tm a_time;
|
||||||
|
char b[ISO_TIME_LEN+1];
|
||||||
|
(void)arg;
|
||||||
|
|
||||||
|
#define T(s) do { \
|
||||||
|
format_iso_time(b, tor_timegm(&a_time)); \
|
||||||
|
tt_str_op(b, ==, (s)); \
|
||||||
|
b[0]='\0'; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/* Test parse_http_time */
|
||||||
|
|
||||||
|
test_eq(-1, parse_http_time("", &a_time));
|
||||||
|
test_eq(-1, parse_http_time("Sunday, 32 Aug 2004 00:48:22 GMT", &a_time));
|
||||||
|
test_eq(-1, parse_http_time("Sunday, 3 Aug 1869 00:48:22 GMT", &a_time));
|
||||||
|
test_eq(-1, parse_http_time("Sunday, 32-Aug-94 00:48:22 GMT", &a_time));
|
||||||
|
test_eq(-1, parse_http_time("Sunday, 3-Ago-04 00:48:22", &a_time));
|
||||||
|
test_eq(-1, parse_http_time("Sunday, August the third", &a_time));
|
||||||
|
test_eq(-1, parse_http_time("Wednesday,,04 Aug 1994 00:48:22 GMT", &a_time));
|
||||||
|
|
||||||
|
test_eq(0, parse_http_time("Wednesday, 04 Aug 1994 00:48:22 GMT", &a_time));
|
||||||
|
test_eq((time_t)775961302UL, tor_timegm(&a_time));
|
||||||
|
T("1994-08-04 00:48:22");
|
||||||
|
test_eq(0, parse_http_time("Wednesday, 4 Aug 1994 0:48:22 GMT", &a_time));
|
||||||
|
test_eq((time_t)775961302UL, tor_timegm(&a_time));
|
||||||
|
T("1994-08-04 00:48:22");
|
||||||
|
test_eq(0, parse_http_time("Miercoles, 4 Aug 1994 0:48:22 GMT", &a_time));
|
||||||
|
test_eq((time_t)775961302UL, tor_timegm(&a_time));
|
||||||
|
T("1994-08-04 00:48:22");
|
||||||
|
test_eq(0, parse_http_time("Wednesday, 04-Aug-94 00:48:22 GMT", &a_time));
|
||||||
|
test_eq((time_t)775961302UL, tor_timegm(&a_time));
|
||||||
|
T("1994-08-04 00:48:22");
|
||||||
|
test_eq(0, parse_http_time("Wednesday, 4-Aug-94 0:48:22 GMT", &a_time));
|
||||||
|
test_eq((time_t)775961302UL, tor_timegm(&a_time));
|
||||||
|
T("1994-08-04 00:48:22");
|
||||||
|
test_eq(0, parse_http_time("Miercoles, 4-Aug-94 0:48:22 GMT", &a_time));
|
||||||
|
test_eq((time_t)775961302UL, tor_timegm(&a_time));
|
||||||
|
T("1994-08-04 00:48:22");
|
||||||
|
test_eq(0, parse_http_time("Wed Aug 04 00:48:22 1994", &a_time));
|
||||||
|
test_eq((time_t)775961302UL, tor_timegm(&a_time));
|
||||||
|
T("1994-08-04 00:48:22");
|
||||||
|
test_eq(0, parse_http_time("Wed Aug 4 0:48:22 1994", &a_time));
|
||||||
|
test_eq((time_t)775961302UL, tor_timegm(&a_time));
|
||||||
|
T("1994-08-04 00:48:22");
|
||||||
|
test_eq(0, parse_http_time("Mie Aug 4 0:48:22 1994", &a_time));
|
||||||
|
test_eq((time_t)775961302UL, tor_timegm(&a_time));
|
||||||
|
T("1994-08-04 00:48:22");
|
||||||
|
test_eq(0, parse_http_time("Sun, 1 Jan 2012 00:00:00 GMT", &a_time));
|
||||||
|
test_eq((time_t)1325376000UL, tor_timegm(&a_time));
|
||||||
|
T("2012-01-01 00:00:00");
|
||||||
|
test_eq(0, parse_http_time("Mon, 31 Dec 2012 00:00:00 GMT", &a_time));
|
||||||
|
test_eq((time_t)1356912000UL, tor_timegm(&a_time));
|
||||||
|
T("2012-12-31 00:00:00");
|
||||||
|
test_eq(-1, parse_http_time("2004-08-zz 99-99x99 GMT", &a_time));
|
||||||
|
test_eq(-1, parse_http_time("2011-03-32 00:00:00 GMT", &a_time));
|
||||||
|
test_eq(-1, parse_http_time("2011-03-30 24:00:00 GMT", &a_time));
|
||||||
|
test_eq(-1, parse_http_time("2011-03-30 23:60:00 GMT", &a_time));
|
||||||
|
test_eq(-1, parse_http_time("2011-03-30 23:59:62 GMT", &a_time));
|
||||||
|
test_eq(-1, parse_http_time("1969-03-30 23:59:59 GMT", &a_time));
|
||||||
|
test_eq(-1, parse_http_time("2011-00-30 23:59:59 GMT", &a_time));
|
||||||
|
test_eq(-1, parse_http_time("2011-03-30 23:59", &a_time));
|
||||||
|
|
||||||
|
#undef T
|
||||||
|
done:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_util_config_line(void)
|
test_util_config_line(void)
|
||||||
{
|
{
|
||||||
|
@ -1314,6 +1384,7 @@ test_util_di_ops(void)
|
||||||
|
|
||||||
struct testcase_t util_tests[] = {
|
struct testcase_t util_tests[] = {
|
||||||
UTIL_LEGACY(time),
|
UTIL_LEGACY(time),
|
||||||
|
UTIL_TEST(parse_http_time, 0),
|
||||||
UTIL_LEGACY(config_line),
|
UTIL_LEGACY(config_line),
|
||||||
UTIL_LEGACY(strmisc),
|
UTIL_LEGACY(strmisc),
|
||||||
UTIL_LEGACY(pow2),
|
UTIL_LEGACY(pow2),
|
||||||
|
|
Loading…
Reference in New Issue