commit 8f69d784be6830b62bcaa9739e39043e240ebb4c Author: Karsten Loesing karsten.loesing@gmx.net Date: Fri Apr 7 15:19:44 2017 +0200
Don't skip unrecognized lines in certain cases.
When we started using Java 7's switch-on-String in 2b4d773, 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. --- CHANGELOG.md | 7 +++++++ .../org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java | 4 ++-- .../torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java | 8 ++++++++ .../org/torproject/descriptor/impl/ServerDescriptorImplTest.java | 8 ++++++++ 4 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b85361..0cb2acd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# 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 diff --git a/src/main/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java b/src/main/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java index d4be77a..136f31e 100644 --- a/src/main/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java +++ b/src/main/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java @@ -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) { diff --git a/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java b/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java index 096314e..c29df8c 100644 --- a/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java +++ b/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java @@ -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 { diff --git a/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java b/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java index 4370321..80dc815 100644 --- a/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java +++ b/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java @@ -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"
tor-commits@lists.torproject.org