Clean up some uses of low-level control replies

Part of ticket 30889.
This commit is contained in:
Taylor Yu 2019-06-17 15:08:11 -05:00
parent aec359ef62
commit 0dd59fdb56
2 changed files with 7 additions and 12 deletions

View File

@ -151,12 +151,8 @@ handle_control_authchallenge(control_connection_t *conn,
goto fail;
}
if (args->kwargs == NULL || args->kwargs->next != NULL) {
/* connection_write_str_to_buf("512 AUTHCHALLENGE requires exactly "
"2 arguments.\r\n", conn);
*/
control_printf_endreply(conn, 512,
"AUTHCHALLENGE dislikes argument list %s",
escaped(args->raw_body));
control_write_endreply(conn, 512,
"Wrong number of arguments for AUTHCHALLENGE");
goto fail;
}
if (strcmp(args->kwargs->key, "")) {

View File

@ -703,9 +703,8 @@ handle_control_mapaddress(control_connection_t *conn,
connection_buf_add(r, sz, TO_CONN(conn));
tor_free(r);
} else {
const char *response =
"512 syntax error: not enough arguments to mapaddress.\r\n";
connection_buf_add(response, strlen(response), TO_CONN(conn));
control_write_endreply(conn, 512, "syntax error: "
"not enough arguments to mapaddress.");
}
SMARTLIST_FOREACH(reply, char *, cp, tor_free(cp));
@ -845,7 +844,7 @@ handle_control_extendcircuit(control_connection_t *conn,
"addresses that are allowed by the firewall configuration; "
"circuit marked for closing.");
circuit_mark_for_close(TO_CIRCUIT(circ), -END_CIRC_REASON_CONNECTFAILED);
connection_write_str_to_buf("551 Couldn't start circuit\r\n", conn);
control_write_endreply(conn, 551, "Couldn't start circuit");
goto done;
}
circuit_append_new_exit(circ, info);
@ -1876,7 +1875,7 @@ handle_control_add_onion(control_connection_t *conn,
char *encoded = rend_auth_encode_cookie(ac->descriptor_cookie,
auth_type);
tor_assert(encoded);
connection_printf_to_buf(conn, "250-ClientAuth=%s:%s\r\n",
control_printf_midreply(conn, 250, "ClientAuth=%s:%s",
ac->client_name, encoded);
memwipe(encoded, 0, strlen(encoded));
tor_free(encoded);