Introduce size limit in ftdi_get_eeprom_buf()
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Sat, 15 Jan 2011 17:32:47 +0000 (18:32 +0100)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Sat, 15 Jan 2011 17:32:47 +0000 (18:32 +0100)
src/ftdi.c

index c9e8892..4cc55e4 100644 (file)
@@ -3257,7 +3257,13 @@ int ftdi_get_eeprom_buf(struct ftdi_context *ftdi, unsigned char * buf, int size
 {
     if (!ftdi || !(ftdi->eeprom))
         ftdi_error_return(-1, "No appropriate structure");
+
+    // Only copy up to FTDI_MAX_EEPROM_SIZE bytes
+    if (size > FTDI_MAX_EEPROM_SIZE)
+        size = FTDI_MAX_EEPROM_SIZE;
+
     memcpy(buf, ftdi->eeprom->buf, size);
+
     return 0;
 }