Opened 13 years ago

#408 closed defect (Fixed)

Java-Exception when trying to get config with default value

Reported by: karsten Owned by: nickm
Priority: Low Milestone:
Component: Tor - Tor Control Panel Version:
Severity: Keywords:
Cc: karsten Actual Points:
Parent ID: Points:
Reviewer: Sponsor:


When requesting a configuration option that is set to a 'default' value semantically different from an empty string,
i.e. Tor replies with a reply line of the form: "250 keyword", the Java Tor controller throws the following exception:

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1

at java.lang.String.substring(Unknown Source)
at net.freehaven.tor.control.TorControlConnection1.getConf(
at net.freehaven.tor.control.TorControlConnection.getConf(

An example for this is requesting the configuration for "DirServer" without having specified such an option in the
configuration file. The result from Tor is just "DirServer", not "DirServer=nodeXY...".

The explanation is that the following code (from TorControlConnection1) assumes that every line is formatted as
"key=value" which is not the case:

for (Iterator it = lst.iterator(); it.hasNext(); ) {

String kv = ((ReplyLine);
int idx = kv.indexOf('=');
result.add(new ConfigEntry(kv.substring(0, idx),



A possible solution could be to create and add a ConfigEntry only if idx != -1. At least, this works for DirServer.

[Automatically added by flyspray2trac: Operating System: All]

Child Tickets

Change History (2)

comment:1 Changed 13 years ago by nickm

Fixed in my local svk repository; I should get it checked in some time tonight. Thanks!

comment:2 Changed 13 years ago by nickm

flyspray2trac: bug closed.

Note: See TracTickets for help on using tickets.