* i2psnark: Fix decoding of negative numbers (ticket #1307)

This commit is contained in:
zzz
2014-06-10 19:54:05 +00:00
parent 1bf8fd92e4
commit 662fe3ebc2
3 changed files with 24 additions and 4 deletions

View File

@ -21,6 +21,7 @@
package org.klomp.snark.bencode;
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
@ -232,10 +233,8 @@ public class BDecoder
if (c == '-')
{
c = read();
if (c == '0')
throw new InvalidBEncodingException("Negative zero not allowed");
chars.append((char)c);
c = read();
}
if (c < '1' || c > '9')
@ -376,4 +375,21 @@ public class BDecoder
return result;
}
/**
* prints out the decoded data
* @since 0.9.14
*/
public static void main(String[] args) {
if (args.length != 1) {
System.err.println("Usage: BDecoder file.torrent");
System.exit(1);
}
try {
BEValue bev = bdecode(new FileInputStream(args[0]));
System.out.println(bev.toString());
} catch (IOException ioe) {
ioe.printStackTrace();
System.exit(1);
}
}
}

View File

@ -1,3 +1,7 @@
2014-06-10 zzz
* i2psnark: Fix decoding of negative numbers (ticket #1307)
* NewsFetcher: Only treat correct status codes as success
2014-06-09 zzz
* i2psnark:
- Show client version if available

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 5;
public final static long BUILD = 6;
/** for example "-test" */
public final static String EXTRA = "";