summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-01-19 13:26:23 -0500
committerNick Mathewson <nickm@torproject.org>2011-01-19 13:26:23 -0500
commitf6a25a995ea120b4415058131a01bc69542280e9 (patch)
tree7b3c95a19d4e0c664d8e34355af936cd6b4551e5 /src
parent670ff24788aa3e4b65afef0b17b883211a520adc (diff)
parenta793f1f6f2bd7b774e3b001468df4ea72bdeffc4 (diff)
downloadtor-f6a25a995ea120b4415058131a01bc69542280e9.tar.gz
tor-f6a25a995ea120b4415058131a01bc69542280e9.zip
Merge remote branch 'origin/maint-0.2.2'
Diffstat (limited to 'src')
-rw-r--r--src/or/routerparse.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 2bd370a056..2e9f7174bf 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -1708,6 +1708,10 @@ extrainfo_parse_entry_from_string(const char *s, const char *end,
authority_cert_t *
authority_cert_parse_from_string(const char *s, const char **end_of_string)
{
+ /** Reject any certificate at least this big; it is probably an overflow, an
+ * attack, a bug, or some other nonsense. */
+#define MAX_CERT_SIZE (128*1024)
+
authority_cert_t *cert = NULL, *old_cert;
smartlist_t *tokens = NULL;
char digest[DIGEST_LEN];
@@ -1735,6 +1739,12 @@ authority_cert_parse_from_string(const char *s, const char **end_of_string)
++eos;
len = eos - s;
+ if (len > MAX_CERT_SIZE) {
+ log_warn(LD_DIR, "Certificate is far too big (at %lu bytes long); "
+ "rejecting", (unsigned long)len);
+ return NULL;
+ }
+
tokens = smartlist_create();
area = memarea_new();
if (tokenize_string(area,s, eos, tokens, dir_key_certificate_table, 0) < 0) {
@@ -3818,6 +3828,9 @@ get_next_token(memarea_t *area,
/** Reject any object at least this big; it is probably an overflow, an
* attack, a bug, or some other nonsense. */
#define MAX_UNPARSED_OBJECT_SIZE (128*1024)
+ /** Reject any line at least this big; it is probably an overflow, an
+ * attack, a bug, or some other nonsense. */
+#define MAX_LINE_LENGTH (128*1024)
const char *next, *eol, *obstart;
size_t obname_len;
@@ -3837,6 +3850,10 @@ get_next_token(memarea_t *area,
eol = memchr(*s, '\n', eos-*s);
if (!eol)
eol = eos;
+ if (eol - *s > MAX_LINE_LENGTH) {
+ RET_ERR("Line far too long");
+ }
+
next = find_whitespace_eos(*s, eol);
if (!strcmp_len(*s, "opt", next-*s)) {