Commit 4488b530 authored by Niels Möller's avatar Niels Möller

Bugfixes to get the new return value conventions to work.

Rev: src/abstract_io.h:1.15
Rev: src/client_keyexchange.c:1.12
Rev: src/read_line.c:1.9
Rev: src/read_packet.c:1.20
Rev: src/server_keyexchange.c:1.10
parent b547c064
......@@ -55,6 +55,8 @@ struct abstract_read
#define LSH_OK 0
#define LSH_FAIL 1
#define LSH_FAILUREP(x) ((x) & 1)
/* Actions */
#define LSH_GOON 0
#define LSH_CLOSE 2
......
......@@ -63,7 +63,7 @@ static int do_handle_dh_reply(struct packet_handler *c,
if (!dh_process_server_msg(&closure->dh, packet))
{
disconnect_kex_failed(connection, "Bad dh-reply\r\n");
return LSH_FAILURE | LSH_CLOSE;
return LSH_FAIL | LSH_CLOSE;
}
v = LOOKUP_VERIFIER(closure->verifier, closure->dh.server_key);
......@@ -72,7 +72,7 @@ static int do_handle_dh_reply(struct packet_handler *c,
/* FIXME: Use a more appropriate error code? */
{
disconnect_kex_failed(connection, "Bad server host key\r\n");
return LSH_FAILURE | LSH_CLOSE;
return LSH_FAIL | LSH_CLOSE;
}
if (!dh_verify_server_msg(&closure->dh, v))
......
......@@ -75,11 +75,18 @@ static int do_read_line(struct read_handler **h,
MDEBUG(closure);
n = A_READ(read, MAX_LINE - closure->pos, closure->buffer);
if (n<0)
switch(n)
{
return 0;
case 0:
return LSH_OK | LSH_GOON;
case A_FAIL:
/* Fall throw */
case A_EOF:
/* FIXME: Free associated resources! */
return LSH_FAIL | LSH_DIE;
}
closure->pos += n;
/* Loop over all recieved lines */
......@@ -112,37 +119,42 @@ static int do_read_line(struct read_handler **h,
if (next)
{
/* Read no more lines. Instead, pass remaining data to next,
* and return a new read-handler. */
* and install the new read-handler. */
if (closure->pos)
{
int res;
struct string_read read =
{ { STATIC_HEADER do_string_read },
closure,
0 };
while(next && (read.index < closure->pos))
if (!READ_HANDLER(next, &read.super))
return 0;
{
res = READ_HANDLER(next, &read.super);
if (LSH_PROBLEMP(res))
return res;
}
}
/* No data left */
lsh_free(closure);
*h = next;
return 1;
return LSH_OK | LSH_GOON;
}
else
if (!closure->handler)
{
/* Fail */
return 0;
return LSH_FAIL | LSH_DIE;
}
}
/* Partial line */
if (closure->pos == MAX_LINE)
{
werror("Too long line from server\n");
return 0;
werror("Recieved too long a line\n");
return LSH_FAIL | LSH_DIE;
}
return 1;
return LSH_OK | LSH_GOON;
}
struct read_handler *make_read_line(struct line_handler *handler)
......
......@@ -194,7 +194,7 @@ static int do_read_packet(struct read_handler **h,
switch(n)
{
case 0:
RETURN LSH_OK | LSH_GOON;
return LSH_OK | LSH_GOON;
case A_FAIL:
/* Fall through */
case A_EOF:
......@@ -261,7 +261,7 @@ static int do_read_packet(struct read_handler **h,
closure->computed_mac + closure->pos,
n))
/* FIXME: Free resources */
return 0;
return LSH_FAIL | LSH_DIE;
closure->pos += n;
......
......@@ -64,7 +64,7 @@ static int do_handle_dh_init(struct packet_handler *c,
if (!dh_process_client_msg(&closure->dh, packet))
{
disconnect_kex_failed(connection, "Bad dh-init\r\n");
return LSH_FAIL | LSSH_CLOSE;
return LSH_FAIL | LSH_CLOSE;
}
/* Send server's message, to complete key exchange */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment