client: added assertions on the buffer pointers

The buffer pointers must not exceed the buffer size.
This commit is contained in:
Max Kellermann 2008-10-17 23:29:41 +02:00
parent d691577a96
commit 3689d5e4ed
1 changed files with 6 additions and 0 deletions

View File

@ -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);