Skip to content

Commit

Permalink
v0.1.1 fix unsafe use of read-string
Browse files Browse the repository at this point in the history
  • Loading branch information
aviad committed Sep 30, 2013
1 parent 1caacb3 commit c6a8c00
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
add this to your =project.clj='s =:dependencies=:

#+BEGIN_EXAMPLE
[clj-btc "0.1.0"]
[clj-btc "0.1.1"]
#+END_EXAMPLE

** [[http://maven.apache.org/][Maven]]
#+BEGIN_EXAMPLE
<dependency>
<groupId>clj-btc</groupId>
<artifactId>clj-btc</artifactId>
<version>0.1.0</version>
<version>0.1.1</version>
</dependency>
#+END_EXAMPLE

Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject clj-btc "0.2.0-SNAPSHOT"
(defproject clj-btc "0.1.1"
:description "Clojure bindings for the original (C++) Bitcoin Client"
:url "https://github.com/aviad/clj-btc"
:license {:name "Eclipse Public License"
Expand Down
13 changes: 11 additions & 2 deletions src/clj_btc/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@

(set! *warn-on-reflection* true)

;;; config file related functions
(defn- read-prop-val
"*Safely* Read a string parsed from the properties file, and parse
it as: Integer, Boolean, String. Otherwise, throw an exception."
[inp]
(try (Long/parseLong inp)
(catch NumberFormatException _
(if (contains? #{"true" "false"} inp)
(Boolean/parseBoolean inp)
inp))))

(defn- default-config-file
"Return the full path (as a vector of strings) to the default bitcoin.conf
file, by OS (default Linux). This is in accordance with
Expand All @@ -37,7 +46,7 @@
(with-open [reader (jio/reader file-name)]
(let [props (java.util.Properties.)]
(.load props reader)
(into {} (for [[k v] props] [(keyword k) (read-string v)]))))
(into {} (for [[k v] props] [(keyword k) (read-prop-val v)]))))
testnet (and (integer? (:testnet config))
(> (:testnet config) 0))]
;; add default values
Expand Down

0 comments on commit c6a8c00

Please sign in to comment.