Commit ff786f72 authored by Niels Möller's avatar Niels Möller
Browse files

Define return values for write functions.

Rev: src/abstract_io.h:1.9
Rev: src/keyexchange.c:1.5
Rev: src/read_data.c:1.3
Rev: src/read_packet.c:1.5
parent 8277f436
......@@ -35,7 +35,19 @@ struct read_handler
#define READ_HANDLER(h, read) ((h)->handler(&(h), (read)))
/* FIXME: What should writers return? */
/* Return values for write callbacks
*
* FIXME: Perhaps some more values are needed? What if we want to
* close a file, but not until all data has bee flushed? Perhaps it is
* best not to put too much meaning into the return value, and use it
* as a succes/fail indication only. */
/* Everything is ok */
#define WRITE_OK 1
/* Write failed, and the packet could not be processed or delivered.
* Most likely because of a protocol error */
#define WRITE_CLOSED 0
/* May store a new handler into *w. */
struct abstract_write
......
......@@ -126,7 +126,7 @@ int initiate_keyexchange(struct ssh_connection *connection,
res = A_WRITE(connection->write, format_kex(kex));
if (res && first_packet)
if ( (res == WRITE_OK) && first_packet)
return A_WRITE(connection->write, first_packet);
else
return res;
......
......@@ -25,12 +25,17 @@ static int do_read_data(struct read_handler **h,
/* Fall through */
case A_EOF:
CALLBACK(closure->close_callback);
return 0;
return WRITE_CLOSED;
default:
packet->length = n;
/* FIXME: Use returned value */
A_WRITE(closure->handler, packet);
break;
{
int res;
packet->length = n;
/* FIXME: Use returned value */
res = A_WRITE(closure->handler, packet);
if (res != WRITE_OK)
return res;
break;
}
}
}
}
......
......@@ -173,7 +173,7 @@ int do_read_packet(struct read_handler **h,
break;
}
/* MAC was ok, send packet on */
if (!A_WRITE(closure->handler, closure->buffer))
if (A_WRITE(closure->handler, closure->buffer) != WRITE_OK)
/* FIXME: What now? */
return 0;
......
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