Commit fadcaa4b authored by Karsten Loesing's avatar Karsten Loesing
Browse files

Fix encoding bug in RelayDirectoryImpl and NetworkStatusImpl.

parent 232ea426
......@@ -10,6 +10,10 @@
- Move descriptor digest computation to DescriptorImpl.
- Fix a bug in digest computation by making sure that the
descriptor string actually contains the end token.
- Fix a bug where both RelayDirectoryImpl and all NetworkStatusImpl
subclasses fail to get indexes right if parts of raw descriptor
strings contain non-ASCII chars. In practice, this only affects
version 1 directories which were last archived in 2007.
# Changes in version 1.7.0 - 2017-05-17
......
......@@ -8,6 +8,7 @@ import org.torproject.descriptor.DirSourceEntry;
import org.torproject.descriptor.DirectorySignature;
import org.torproject.descriptor.NetworkStatusEntry;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.SortedMap;
......@@ -33,7 +34,8 @@ public abstract class NetworkStatusImpl extends DescriptorImpl {
if (this.rawDescriptorBytes.length == 0) {
throw new DescriptorParseException("Descriptor is empty.");
}
String descriptorString = new String(rawDescriptorBytes);
String descriptorString = new String(rawDescriptorBytes,
StandardCharsets.US_ASCII);
int firstRIndex = this.findFirstIndexOfKeyword(descriptorString,
Key.R.keyword);
int endIndex = descriptorString.length();
......
......@@ -8,6 +8,7 @@ import org.torproject.descriptor.RelayDirectory;
import org.torproject.descriptor.RouterStatusEntry;
import org.torproject.descriptor.ServerDescriptor;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
......@@ -56,7 +57,8 @@ public class RelayDirectoryImpl extends DescriptorImpl
if (this.rawDescriptorBytes.length == 0) {
throw new DescriptorParseException("Descriptor is empty.");
}
String descriptorString = new String(rawDescriptorBytes);
String descriptorString = new String(rawDescriptorBytes,
StandardCharsets.US_ASCII);
int startIndex = 0;
int firstRouterIndex = this.findFirstIndexOfKeyword(descriptorString,
Key.ROUTER.keyword);
......
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