From 979a145c5ae69c8f6b28da72ad6d9f6a833f61a4 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Mon, 28 Jul 2003 15:51:29 +0000 Subject: [PATCH] libftdi: (tomj) limit ftdi_read buffer size to n*64 bytes, n != 0 --- ftdi/ftdi.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/ftdi/ftdi.c b/ftdi/ftdi.c index 01d8f1a..2ccc2b7 100644 --- a/ftdi/ftdi.c +++ b/ftdi/ftdi.c @@ -216,6 +216,11 @@ int ftdi_read_data(struct ftdi_context *ftdi, unsigned char *buf, int size) { int ret = 1; int offset = 0; + if (size != 0 && size % 64 != 0) { + ftdi->error_str = "Sorry, read buffer size must currently be a multiple (1x, 2x, 3x...) of 64"; + return -2; + } + while (offset < size && ret > 0) { ret = usb_bulk_read (ftdi->usb_dev, 0x81, readbuf, 64, ftdi->usb_timeout); // Skip FTDI status bytes -- 1.7.1