Commit 3689d5e4 authored by Max Kellermann's avatar Max Kellermann

client: added assertions on the buffer pointers

The buffer pointers must not exceed the buffer size.
parent d691577a
...@@ -449,6 +449,9 @@ static int client_input_received(struct client *client, size_t bytesRead) ...@@ -449,6 +449,9 @@ static int client_input_received(struct client *client, size_t bytesRead)
char *newline, *next; char *newline, *next;
int ret; int ret;
assert(client->bufferPos <= client->bufferLength);
assert(client->bufferLength + bytesRead <= sizeof(client->buffer));
client->bufferLength += bytesRead; client->bufferLength += bytesRead;
end = client->buffer + client->bufferLength; end = client->buffer + client->bufferLength;
...@@ -501,6 +504,9 @@ static int client_read(struct client *client) ...@@ -501,6 +504,9 @@ static int client_read(struct client *client)
{ {
ssize_t bytesRead; ssize_t bytesRead;
assert(client->bufferPos <= client->bufferLength);
assert(client->bufferLength < sizeof(client->buffer));
bytesRead = read(client->fd, bytesRead = read(client->fd,
client->buffer + client->bufferLength, client->buffer + client->bufferLength,
CLIENT_MAX_BUFFER_LENGTH - client->bufferLength); CLIENT_MAX_BUFFER_LENGTH - client->bufferLength);
......
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