diff options
author | Max Kellermann <max@duempel.org> | 2008-10-17 23:29:41 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-17 23:29:41 +0200 |
commit | 3689d5e4edebee610799df924d2abb46953d8569 (patch) | |
tree | 7b97e05becf0870f7c2abe74da66b42b394616f1 | |
parent | d691577a96284129133db7c49ecc3c8053560aa5 (diff) | |
download | mpd-3689d5e4edebee610799df924d2abb46953d8569.tar.gz mpd-3689d5e4edebee610799df924d2abb46953d8569.tar.xz mpd-3689d5e4edebee610799df924d2abb46953d8569.zip |
client: added assertions on the buffer pointers
The buffer pointers must not exceed the buffer size.
-rw-r--r-- | src/client.c | 6 |
1 files changed, 6 insertions, 0 deletions
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); |