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

* src/io.c, src/read_line.c, src/read_packet.c, src/read_scan.c: Added

asserts to ensure read() is called with a length > 0. (Ray)

Rev: src/read_line.c:1.22
Rev: src/read_packet.c:1.34
Rev: src/read_scan.c:1.6
parent cd88a091
......@@ -23,6 +23,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <assert.h>
#include <string.h>
#include "read_line.h"
......@@ -81,6 +82,7 @@ static int do_read_line(struct read_handler **h,
struct read_handler *next = NULL;
int n;
assert(MAX_LINE - closure->pos > 0);
n = A_READ(read, MAX_LINE - closure->pos, closure->buffer);
switch(n)
......
......@@ -121,6 +121,7 @@ static int do_read_packet(struct read_handler **h,
int n;
left = block_size - closure->pos;
assert(left > 0);
n = A_READ(read, left, closure->buffer->data + closure->pos);
switch(n)
......@@ -207,8 +208,10 @@ static int do_read_packet(struct read_handler **h,
case WAIT_CONTENTS:
{
UINT32 left = closure->buffer->length - closure->pos;
int n = A_READ(read, left, closure->buffer->data + closure->pos);
int n;
assert(left > 0);
n = A_READ(read, left, closure->buffer->data + closure->pos);
switch(n)
{
case 0:
......
......@@ -24,6 +24,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <assert.h>
#include "read_scan.h"
#include "xalloc.h"
......@@ -51,8 +52,10 @@ static int do_read_scan(struct read_handler **h,
CAST(read_scan, closure, *h);
UINT8 *buffer = alloca(closure->buffer_size);
int n = A_READ(read, closure->buffer_size, buffer);
int n;
int i;
assert(closure->buffer_size > 0);
n = A_READ(read, closure->buffer_size, buffer);
switch(n)
{
......
Supports Markdown
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