From 3689d5e4edebee610799df924d2abb46953d8569 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 17 Oct 2008 23:29:41 +0200 Subject: client: added assertions on the buffer pointers The buffer pointers must not exceed the buffer size. --- src/client.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/client.c b/src/client.c index c97b24b48..0585b0405 100644 --- a/src/client.c +++ b/src/client.c @@ -449,6 +449,9 @@ static int client_input_received(struct client *client, size_t bytesRead) char *newline, *next; int ret; + assert(client->bufferPos <= client->bufferLength); + assert(client->bufferLength + bytesRead <= sizeof(client->buffer)); + client->bufferLength += bytesRead; end = client->buffer + client->bufferLength; @@ -501,6 +504,9 @@ static int client_read(struct client *client) { ssize_t bytesRead; + assert(client->bufferPos <= client->bufferLength); + assert(client->bufferLength < sizeof(client->buffer)); + bytesRead = read(client->fd, client->buffer + client->bufferLength, CLIENT_MAX_BUFFER_LENGTH - client->bufferLength); -- cgit v1.2.3