Commit 8f69d784 authored by Karsten Loesing's avatar Karsten Loesing
Browse files

Don't skip unrecognized lines in certain cases.

When we started using Java 7's switch-on-String in 2b4d7732, we broke
unrecognized line parsing in extra-info descriptors.  Namely, when we
reached the end of a crypto block we didn't reset the list for
collecting crypto lines.  So far so good, but any following
unrecognized lines would be collected as crypto lines and later
discarded, rather than being added to the unrecognized-lines list and
later reported.

This only affects relay descriptors, because sanitized bridge
descriptors don't contain crypto blocks.  And it only affects relay
descriptors with crypto blocks, like "identity-ed25519", whereas relay
extra-info descriptors published by older versions were not affected.

Fixes #21890.
parent a57b1f76
# Changes in version ???
# Medium changes
- Fix a bug where unrecognized lines in extra-info descriptors
below crypto blocks were silently skipped.
# Changes in version 1.6.0 - 2017-02-17
* Major changes
......
......@@ -270,9 +270,9 @@ public abstract class ExtraInfoDescriptorImpl extends DescriptorImpl
}
this.unrecognizedLines.addAll(cryptoLines);
}
cryptoLines = null;
nextCrypto = "";
}
cryptoLines = null;
nextCrypto = "";
break;
default:
if (cryptoLines != null) {
......
......@@ -1805,6 +1805,14 @@ public class ExtraInfoDescriptorImplTest {
+ ROUTER_SIG_ED25519_LINE);
}
@Test(expected = DescriptorParseException.class)
public void testEd25519FollowedbyUnrecognizedLine()
throws DescriptorParseException {
DescriptorBuilder.createWithEd25519Lines(IDENTITY_ED25519_LINES,
MASTER_KEY_ED25519_LINE, ROUTER_SIG_ED25519_LINE
+ "\nunrecognized-line 1");
}
@Test()
public void testExtraInfoDigestSha256Relay()
throws DescriptorParseException {
......
......@@ -1652,6 +1652,14 @@ public class ServerDescriptorImplTest {
+ ROUTER_SIG_ED25519_LINE);
}
@Test(expected = DescriptorParseException.class)
public void testEd25519FollowedbyUnrecognizedLine()
throws DescriptorParseException {
DescriptorBuilder.createWithEd25519Lines(IDENTITY_ED25519_LINES,
MASTER_KEY_ED25519_LINE, ROUTER_SIG_ED25519_LINE
+ "\nunrecognized-line 1");
}
private static final String ONION_KEY_CROSSCERT_LINES =
"onion-key-crosscert\n"
+ "-----BEGIN CROSSCERT-----\n"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment