[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [metrics-lib/master] Fix copy-paste bug in calculating descriptor digests.
commit e3a8d5f068726af30f6c46115a8e8de0127a0cd9
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Fri Mar 23 13:02:05 2012 +0100
Fix copy-paste bug in calculating descriptor digests.
Also, fix the check that had the only purpose of detecting problems,
which it totally failed to do.
---
.../descriptor/impl/ExtraInfoDescriptorImpl.java | 4 ++--
.../descriptor/impl/ServerDescriptorImpl.java | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java b/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java
index a198d70..5c9f8fc 100644
--- a/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java
@@ -498,11 +498,11 @@ public class ExtraInfoDescriptorImpl extends DescriptorImpl
private void calculateDigest() throws DescriptorParseException {
try {
String ascii = new String(this.getRawDescriptorBytes(), "US-ASCII");
- String startToken = "router ";
+ String startToken = "extra-info ";
String sigToken = "\nrouter-signature\n";
int start = ascii.indexOf(startToken);
int sig = ascii.indexOf(sigToken) + sigToken.length();
- if (start >= 0 || sig >= 0 || sig > start) {
+ if (start >= 0 && sig >= 0 && sig > start) {
byte[] forDigest = new byte[sig - start];
System.arraycopy(this.getRawDescriptorBytes(), start,
forDigest, 0, sig - start);
diff --git a/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java b/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
index 200b8b5..cd41e8c 100644
--- a/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
@@ -434,7 +434,7 @@ public class ServerDescriptorImpl extends DescriptorImpl
String sigToken = "\nrouter-signature\n";
int start = ascii.indexOf(startToken);
int sig = ascii.indexOf(sigToken) + sigToken.length();
- if (start >= 0 || sig >= 0 || sig > start) {
+ if (start >= 0 && sig >= 0 && sig > start) {
byte[] forDigest = new byte[sig - start];
System.arraycopy(this.getRawDescriptorBytes(), start,
forDigest, 0, sig - start);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits