summaryrefslogtreecommitdiff
path: root/src/or/control.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-05-15 21:17:48 +0000
committerNick Mathewson <nickm@torproject.org>2007-05-15 21:17:48 +0000
commite043b86f47185e0d9df53dab12d42e46c8c35b83 (patch)
tree0ebfb1bbce0fbcfa7d6e470b98d5bf90e9889a02 /src/or/control.c
parentbfdc366037690c74d1e6b73fc33e2f73842ed793 (diff)
downloadtor-e043b86f47185e0d9df53dab12d42e46c8c35b83.tar.gz
tor-e043b86f47185e0d9df53dab12d42e46c8c35b83.zip
r12764@catbus: nickm | 2007-05-15 17:17:39 -0400
Enable (and cope with) more GCC 4.2 warnings. svn:r10196
Diffstat (limited to 'src/or/control.c')
-rw-r--r--src/or/control.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 3e73510ce3..5100c16866 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -943,13 +943,18 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len,
const char *errstr = NULL;
char *password;
size_t password_len;
+ const char *cp;
+ int i;
if (TOR_ISXDIGIT(body[0])) {
- int i = 0;
- while (TOR_ISXDIGIT(body[i]))
- ++i;
- password = tor_malloc(i/2 + 1);
- if (base16_decode(password, i/2+1, body, i)<0) {
+ cp = body;
+ while (TOR_ISXDIGIT(*cp))
+ ++cp;
+ i = cp - body;
+ tor_assert(i>0);
+ password_len = i/2;
+ password = tor_malloc(password_len + 1);
+ if (base16_decode(password, password_len+1, body, i)<0) {
connection_write_str_to_buf(
"551 Invalid hexadecimal encoding. Maybe you tried a plain text "
"password? If so, the standard requires that you put it in "
@@ -957,7 +962,6 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len,
tor_free(password);
return 0;
}
- password_len = i/2;
} else if (TOR_ISSPACE(body[0])) {
password = tor_strdup("");
password_len = 0;