X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=src%2Fftdi.c;h=6de60bee189ad902ad59753a3f91124cf0e12507;hp=4cc55e4d9857b35ed0a9b6d868299dbf03eaed9c;hb=200bd3ed2e1d2389217be44c0adc728909a2a100;hpb=b95e46548cdf96ef21b3de2a1b3d55ceeca12075 diff --git a/src/ftdi.c b/src/ftdi.c index 4cc55e4..6de60be 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -3252,12 +3252,16 @@ int ftdi_set_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value valu \retval 0: All fine \retval -1: struct ftdi_contxt or ftdi_eeprom missing + \retval -2: Not enough room to store eeprom */ 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"); + if (!buf || size < ftdi->eeprom->size) + ftdi_error_return(-1, "Not enough room to store eeprom"); + // Only copy up to FTDI_MAX_EEPROM_SIZE bytes if (size > FTDI_MAX_EEPROM_SIZE) size = FTDI_MAX_EEPROM_SIZE;