summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-03-02 04:59:52 +0000
committerRoger Dingledine <arma@torproject.org>2004-03-02 04:59:52 +0000
commit08346f13f09f1644de81fde2641954a9a7231cf1 (patch)
treec327144ab267eff1776e3427e357c529ae83e75c
parentf81ad1550ed2d29aea01b5bb024ef93f432b885e (diff)
downloadtor-08346f13f09f1644de81fde2641954a9a7231cf1.tar.gz
tor-08346f13f09f1644de81fde2641954a9a7231cf1.zip
make parse_line_from_file fail rather than warn for malformed lines
svn:r1193
-rw-r--r--src/common/util.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 6cfe36abfa..7cbbca4778 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -621,8 +621,9 @@ char *read_file_to_str(const char *filename) {
}
/* read lines from f (no more than maxlen-1 bytes each) until we
- * get one with a well-formed "key value".
- * point *key to the first word in line, point *value to the second.
+ * get a non-whitespace line. If it isn't of the form "key value"
+ * (value can have spaces), return -1.
+ * Point *key to the first word in line, point *value * to the second.
* Put a \0 at the end of key, remove everything at the end of value
* that is whitespace or comment.
* Return 1 if success, 0 if no more lines, -1 if error.
@@ -661,8 +662,8 @@ try_next_line:
if(!*end || !*value) { /* only a key on this line. no value. */
*end = 0;
- log_fn(LOG_WARN,"Line has keyword '%s' but no value. Skipping.",key);
- goto try_next_line;
+ log_fn(LOG_WARN,"Line has keyword '%s' but no value. Failing.",key);
+ return -1;
}
*end = 0; /* null it out */